Magical BF 4

시간 제한1초메모리 제한1024 MB

요약
행으로 읽으나 열로 읽으나 같은 BF 코드 격자를 만들어, F_1, F_2, k로 F_k를 계산해 M_0에 저장한다.
난이도

어려움10점 중 8점

유형
시뮬레이션, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

John learned at school that in many East Asian languages texts can be written from left to right as well as from top to bottom. He got especially curious whether it's possible to write a text such that it can simultaneously be read both ways. John kept puzzling in programming class as well and now wants to write code such that it would solve the tasks when read by rows (top to bottom and left to right), as well as when read by columns (left to right and top to bottom). Naturally, he needed a suitable language for this and John chose a language called BF for experimenting.

The memory of a BF program is an infinite array MM with cells numbered from left to right (M_0M\_0, M_1M\_1, \ldots). Each cell contains a nonnegative integer that can be arbitrarily large. Additionally there is a data pointer that in the beginning of execution points to the leftmost cell (M_0M\_0).

The execution of a program starts from its first command and in general after the execution of each command the program moves on to the next command in the sequence. Altogether there are six commands in the language, each one denoted by one character:

CommandMeaning
>Moves the data pointer to the right by one cell.
<Moves the data pointer to the left by one cell if the data pointer does not point to the leftmost cell; otherwise does nothing.
+Increases the cell at the data pointer by one.
-Decreases the cell at the data pointer by one if the cell is currently positive; otherwise does nothing.
[If the cell at the data pointer is zero, then jumps forward to the corresponding ']' symbol; otherwise does nothing.
]If the cell at the data pointer is nonzero, then jumps back to the corresponding '[' symbol; otherwise does nothing.

Help John write magical BF programs for solving the five tasks listed below.

As a solution to each task submit an N×NN \times N grid of BF program code (where 1≤N≤10001 \le N \le 1000). The code does not have to be the same when read by rows and by columns, but must solve the task correctly in both cases. The solution text can only contain the characters '>', '<', '+', '-', '[' and ']' and must completely fill the grid. For any allowed input, the code must not execute more than 1010 million commands.

Task: The cell M_0M\_0 contains an integer kk (3≤k≤103 \le k \le 10) and the cells M_1M\_1 and M_2M\_2 contain the integers F_1F\_1 and F_2F\_2 (1≤F_1≤31 \le F\_1 \le 3, 1≤F_2≤31 \le F\_2 \le 3). The elements of the sequence F_iF\_i for i>2i > 2 are defined by the rule F_i=F_i−1+F_i−2F\_{i} = F\_{i-1} + F\_{i-2}. Find the value of F_kF\_k and write it into the cell M_0M\_0. By the end of the execution all cells other than M_0M\_0 may contain any numbers.

Input example:

Output example:

예제

이 문제는 공개된 예제가 없습니다.