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

6796번 - Punchy 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB24513811960.714%

문제

In the early days of computing, instructions had to be “punched” onto rectangular cards, one instruction per card. This card deck was then fed into a card reader so the program could be read and executed. Students put elastic bands around their card deck, and, often, carried their cards in a box for fear that they would become rearranged, and thus, their program would be incorrect.

Poor Bill though...he left his cards right near a window and the wind blew his neat deck of cards all over the place, and thus his program is out of order! Bill decides to pick up the cards in some random order and then execute the program.

Write a program to read and execute the commands in Bill’s “new” program.

입력

The programming language that Bill is using has only two variables (A and B) and seven different types of instructions.

Initially, the variables A and B contain the value 0.

There is one instruction per line. An instruction is an integer in the range 1...7, possibly followed by a variable name, which in turn is possibly followed by either a number or a variable.

In all instructions below, the variable X or Y may refer to either A or B. The specific instructions are:

  • 1 X n means set the variable X to the integer value n;
  • 2 X means output the value of variable X to the screen;
  • 3 X Y means calculate X + Y and store the value in variable X;
  • 4 X Y means calculate X ∗ Y and store the value in variable X;
  • 5 X Y means calculate X − Y and store the value in variable X;
  • 6 X Y means calculate the quotient of X/Y and store the value in variable X as an integer, discarding the remainder.
  • 7 means stop execution of this program.

You may assume that all division instructions do not cause a division by zero, and that all other operations (including instruction 1) do not cause the computed/stored value to be larger than 10,000 or smaller than -10,000.

(To clarify division of negative numbers, −3/2 and 3/ − 2 both have quotient −1 and −3/ − 2 has quotient 1.)

출력

Your program should output the value of the indicated variables, one integer per line, until the “stop” instruction has been read in, at which time your program should stop execution.

제한

예제 입력 1

1 A 3
1 B 4
2 B
2 A
3 A B
2 A
5 A A
2 A
2 B
7

예제 출력 1

4
3
7
0
4

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2010 > CCC 2010 Junior Division 3번

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

출처

대학교 대회

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

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