ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

Quarterfinal, Rybinsk, October 16 2003

About     Problems     Submit solution     Judge status     Standings
Contest is over

E. “… Connecting People”

Time limit: 1.0 second
Memory limit: 64 MB
A new model of a mobile phone is powered by a special sound generation processor, developed expressly for this purpose.
The processor has a sound generator, an instruction pointer (IP), command memory (100 cells) and a stack (100 cells).
The instruction set of this processor consists of the two commands only:
CALL X – a subroutine call command – pushes the incremented current value of the IP (the return address) on the top of the stack and sets the IP to X;
BELL&RET – the combined command “bell-return” – emits a sound of a fixed (unit) duration and performs control return (pops a value from the top of the stack and assigns it to the IP) or stops the execution of the program (if the stack is empty).
Any command (together with its operand) occupies exactly one memory cell.
The return address occupies only one cell on the stack, too.
The work cycle of the processor starts when it is necessary to emit a sound. At this moment the IP points to the zero memory cell. The processor stops its work if the stack is empty after emitting a sound (when BELL&RET command has been executed).
The manufacturers of the processor affirm that by using of this processor may be emitted sound of rather long duration.
Your task is to write a program, which accepts K as input and produces a program for this processor to emit a sound of duration K.
The resulting program may have no more than 100 commands including exactly one BELL&RET command, being always the last one.
Unused memory cells following the BELL&RET command are considered free.


There will be one integer number K in the input (0 < K ≤ 109) – sound duration.


Output a program for the processor described above. The execution of this program leads to emission of the sound of duration K. The first line should correspond to the zero cell of the memory, the second line – to the first cell, the third – to the second one etc. All lines, with exception for the last one, may contain only CALL commands. The operand of the CALL command is an integer (from 1 to 99) and must be separated from the command by a white-space character.
The last line must contain the BELL&RET command.


Problem Author: © Sergey G. Volchenkov, 2003(volchenkov@yandex.ru); Vladimir N. Pinaev, 2003(vpinaev@mail.ru; http://www.pic200x.chat.ru); Michael Y. Kopachev, 2003 (mkopachev@krista.ru).
Problem Source: 2003-2004 ACM Central Region of Russia Quarterfinal Programming Contest, Rybinsk, October 15-16, 2003
To submit the solution for this problem go to the Problem set: 1278. “… Connecting People”