| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 0 | 0 | 0 | 0.000% |
Justas often participates in programming olympiads. Since he spends a lot of time solving tasks, Justas decided to try and automate task solving. He would like to have a program to which he would provide task tests and the program would find task solution. Unfortunately, Justas doesn’t know how to write such program. Help him!
Justas will give you a list of tests and you will have to find a solution that would correctly solve all those tests. Each test consists of two numbers – an initial number and a result. The initial number of each test is unique.
Justas is using a very simple programming language. The language has one variable X, which holds a non-negative integer number of any size (X ≥ 0). Once the program starts, test’s initial number is written to the variable. The program consists of list of commands:
Bear in mind that answer can be output in a few ways. For example, if we have a program:
multiply 2 print add 5 print
If the initial number was 1, the program would output 27. If the initial number was 6, the output would be 1217.
Justas wants the program to fit into the time limit, therefore you need to find the shortest program which produces correct outputs for all tests that Justas will provide.
The first line contains the integer N – the number of tests. The next N lines contain two integers each – ai and bi. ai is the initial number of the i-th test, and bi is the output that should be produced. All ai values are unique.
The first line should contain a single integer K – the smallest number of commands that make up the needed program. The next K lines should contain the commands of the program – one command per line.
If there are multiple possible outputs, you can output any one of them. If there is no program that can solve all provided tests, output −1.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 9 | N = 1 |
| 2 | 17 | ai, bi < 100 for all values of i |
| 3 | 53 | ai, bi < 109 for all values of i |
| 4 | 21 | No additional limitations |
3 2 12 3 18 5 30
2 multiply 6 print
In every test, the answer is 6 times bigger than the initial value, thus it’s enough to multiply by 6 and print.
2 2 47 43 8689
4 multiply 2 print add 3 print
For the first test, the program prints number 47 as "4" and "7". For the second test, number 8689 is printed as "86" and "89".
2 1 3 2 2
-1
There is no program that could output 3 when input is 1, and output 2 when input is 2.
Olympiad > Lithuanian Olympiad in Informatics > Lithuanian Olympiad in Informatics 2017/2018 > National Round (2) > 10-12 Classes ?번