#P8429. [COI 2020] Semafor
[COI 2020] Semafor
Description
Matej's first step is to apply this design to the football industry. He is currently giving a presentation at the Croatian Football Federation, planning to use his design on the substitution board.
The substitution board consists of five-segment LED displays. The board will show a number made of digits, representing the jersey number of the player being substituted off. Matej decides to start demonstrating how his board works. At the beginning, his board shows the number . Matej will perform one of the following two operations:
- Turn on one LED segment that is currently off.
- Turn off one LED segment that is currently on.
Matej will perform a total of operations. He must ensure that after every operations, the board shows a valid number (i.e., each five-segment LED display shows a digit from to ).
After performing operations, you will get a final state. For each final state that is a valid number, Matej wants to know how many different operation sequences satisfying the above restriction can reach that final state. We say two operation sequences are different if and only if, at the -th operation, they operate on different five-segment LED displays, and after some operation the two sequences result in different states.
Input Format
The first line contains four integers , as described above.
Output Format
Output lines. On the -th line, output an integer denoting the number of operation sequences such that the final displayed number is . Output the answer modulo .
1 2 1 5
0
0
0
1
0
2
0
0
0
0
1 3 3 8
0
0
0
6
0
13
0
0
0
0
1 4 2 4
24
0
8
0
37
0
4
28
4
24
Hint
Explanation for Sample 1
At the beginning, the substitution board shows . Since , after each operation the board must show a valid number. Matej will perform operations, so in the end he can display either or . To display , we can only first change into , and then change into . To display , we can do it either by or by , so there are two operation sequences.
Constraints
This problem uses bundled testdata.
- Subtask 1 (6 pts): , .
- Subtask 2 (15 pts): , .
- Subtask 3 (12 pts): , , .
- Subtask 4 (12 pts): , , .
- Subtask 5 (15 pts): , , .
- Subtask 6 (40 pts): , .
For of the testdata, , .
Notes
Translated from Croatian Olympiad in Informatics 2020 C Semafor。
Translated by ChatGPT 5
京公网安备 11011102002149号