Logo
(追記) (追記ここまで)

34430번 - Tax Calc 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB17121280.000%

문제

The King wants a calculator to determine how much tax his kingdom is collecting, and he has chosen you to complete this task for him.

As you listen to the King, you realize there are several problems. The first is that some people, in an attempt to dodge taxes, don't just report a number--instead, they report some complex calculation! Sadly, you have to tabulate these people's taxes just like everyone else's. The second problem is that, over the years, the tax code of the Kingdom has gotten very complex. That is, instead of just simple additions, some tax calculations include subtraction and division (although not multiplication--that's illegal in the Kingdom). You will have to make sure you count these taxes appropriately as well.

Given a tax calculation, you need to report the total amount of tax collected. A tax calculation might, for example, be provided as the following:

( + 50 70 ( / 300 4 ) ).

This means that three people have paid a tax (the Kingdom is not large). The first two reported a constant amount, while the third reported their tax as a quotient instead. The King needs you to sum the taxes paid by each taxpayer to determine the total.

입력

The input consists of one line containing a tax calculation. A tax calculation begins with ( and ends with ). Between each set of parentheses, there will be one operator (+, -, or /). After the operator will be between 2 and 1000 tax reportings.

Each tax reporting may be either a single integer $i$ (1ドル \leq i \leq 100\ 000$), or it may be a subcalculation. A subcalculation begins with ( and ends with ). Between these parentheses, there will be one operator (+, -, or /). After the operator will be between 2 and 1000 integers $i$ (1ドル \leq i \leq 100\ 000$).

Each item (paren, operator, tax reporting, or any corresponding subcalculation component) will be separated from every other item by one space.

If a calculation or subcalculation begins with the operator - or the operator /, then there will only be two following reportings (for a calculation) or integers (for subcalculations).

No quotient will have a fractional result, but some differences may be negative.

출력

Output the total tax collected.

제한

예제 입력 1

( + 50 70 ( / 300 4 ) )

예제 출력 1

195

노트

출처

School > CS@Mines > CS@Mines HSPC 2020 G번

  • 문제를 만든 사람: Jordan Newport
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /