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

24830번 - Broken Calculator 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB63036832059.813%

문제

Working on math homework late one night, you realized your calculator is broken. When it performs "addition" it adds the two numbers entered, then subtracts the result from the previous operation. When it performs "subtraction" it subtracts the two numbers entered, then multiplies the result by the previous operation's result. When it performs "multiplication" it squares its answer after multiplying the two numbers entered. When it performs "division" it divides the first number by 2ドル$ if it is even, otherwise it adds 1ドル$ to the first number and divides it by 2ドル$.

You also notice that when the calculator is turned on the previous operation's result is set to 1. You realize that doing math homework this way makes it more fun and want to write a program to perform calculations like your broken calculator.

You spoke to your teacher about your broken calculator and they gave you the guarantee that even with this weird behavior your calculator will never have to compute numbers larger than one quintillion (10ドル^{18}$) on your upcoming homework assignments.

입력

The input will begin with an integer $n$ (1ドル \le n \le 1,000円$), the number of commands you want to run on your calculator. Following the first line, each line will have an integer number $a,ドル an operator $op,ドル and a number $b,ドル separated by a single space, which denote the first operand, the operation, and the second operand, respectively. The operator will be one of +, -, *, or /. The operands will be in the range 0ドル \le a, b \le 100,000円$.

출력

Print the answer the calculator will show after running the command on each line, assuming it is turned on before the first line is entered and stays on for all subsequent lines of input.

제한

예제 입력 1

5
4 * 5
2 + 5
3 - 1
20 / 3
13 / 24

예제 출력 1

400
-393
-786
10
7

힌트

출처

School > Virginia Tech High School Programming Contest > 2019 Virginia Tech High School Programming Contest M번

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

출처

대학교 대회

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

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