시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
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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IDMgc3BhY2VzLiZuYnNwOzxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPk91dHB1dCBzaG91bGQgY29udGFpbiBhbGwgdGhlIG91dHB1dHMgZnJvbSBQUklOVCBjb21tYW5kcyBkdXJpbmcgdGhlIHByb2dyYW0gZXhlY3V0aW9uLiZuYnNwOzxcL3A+XHJcblxyXG48cD5Ob3RlOiBpbnB1dCB3aWxsIGJlIHN1Y2ggdGhhdCB0aGUgUFJJTlQgY29tbWFuZCB3aWxsIGV4ZWN1dGUgYXQgbW9zdCAyMCB0aW1lcy4mbmJzcDs8XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

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

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