시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 64 3 3 13.043%

문제

프로그래밍 언어 Z에는 변수를 26가지 사용할 수 있다. 이 변수는 모두 알파벳 소문자 (a-z)이고, 초기값은 0이다.

프로그램이 수행되는 동안 각 변수에는 0보다 크거나 같고, 9999보다 작거나 같은 정수만 저장할  수 있다. 만약, 범위를 넘어가는 값을 변수에 저장하려 한다면, 10,000으로 나눈 나머지를 저장한다.

프로그램의 각 줄에는 명령어가 하나만 등장하며, 아래 5가지 중 하나이다.

BEGIN 프로그램의 가장 첫 줄에 나온다.
= 연산자의 왼쪽에 있는 변수에, 오른쪽에 있는 식의 결과를 저장한다. 식은 하나 또는 그 이상의 덧셈, 뺄셈으로 이루어져 있고, 각 항은 상수 또는 변수이다. 이때, 변수의 앞에 상수가 붙어있을 수도 있고 이때는 그 변수를 상수만큼 곱하면 된다. (a = 2b + 4 - c) 모든 연산자의 앞, 뒤는 공백이다. 상수는 0보다 크거나 같고, 999보다 작거나 같은 정수이다.
REPEAT n 블록의 시작을 나타내며, 그 블록을 n번 반복한다. (1 <= n <= 100,000)
STOP 블록의 끝을 나타낸다.
PRINT var 변수 var에 저장되어 있는 값을 'var = value'와 같은 형태로 출력한다.

프로그래밍 언어 Z로 된 프로그램이 주어졌을 때, 화면에 출력되는 내용을 출력하는 프로그램을 작성하시오.

입력

입력은 프로그래밍 언어 Z로 되어있는 프로그램이 주어진다. 이 프로그램은 최대 50줄이다. 각 줄에는 명령어가 하나씩 있고, 이 명령은 100자 이내이다. BEGIN…STOP, REPEAT…STOP은 공백 3칸씩 인덴트 되어 있다. PRINT는 최대 20번 실행 된다.

출력

프로그램을 수행하면서 PRINT가 나올 때 마다, 그 결과를 출력한다.

예제 입력 1

BEGIN
   a = 1
   b = a
   PRINT a
   PRINT b
   REPEAT 10
      c = a + b
      a = b
      b = c
      PRINT c
   STOP
STOP

예제 출력 1

a = 1
b = 1
c = 2
c = 3
c = 5
c = 8
c = 13
c = 21
c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dpbGwgYmUgaW5kZW50ZWQgZXhhY3RseSAzIHNwYWNlcy4mbmJzcDs8XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5PdXRwdXQgc2hvdWxkIGNvbnRhaW4gYWxsIHRoZSBvdXRwdXRzIGZyb20gUFJJTlQgY29tbWFuZHMgZHVyaW5nIHRoZSBwcm9ncmFtIGV4ZWN1dGlvbi4mbmJzcDs8XC9wPlxyXG5cclxuPHA+Tm90ZTogaW5wdXQgd2lsbCBiZSBzdWNoIHRoYXQgdGhlIFBSSU5UIGNvbW1hbmQgd2lsbCBleGVjdXRlIGF0IG1vc3QgMjAgdGltZXMuJm5ic3A7PFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2005 > Final Exam #1 2번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: doju
  • 빠진 조건을 찾은 사람: sys7961