#P2817. 宋荣子的城堡
宋荣子的城堡
Description
saruka owns a big castle. There are rooms in the castle, and each room has a number written on it. One day, saruka invited his friends LYL and MagHSK to play in the castle. They agreed that if someone is currently standing in room , then on the next step they must go to room , and on the following step to room .
To make it more interesting, saruka decides to rewrite each to satisfy the following:
-
If you start from any room numbered from and follow the rule, you must be able to return to room . In particular, if you start from room , you must return to room as well (you must take at least one step; if , moving from to is also considered valid).
-
If you start from any room with a number greater than and follow the rule, you must never reach room .
saruka wants to know how many assignments of satisfy the requirements. Output the answer modulo .
Input Format
A single line containing two integers , as described.
Output Format
Output a single integer, the number of valid assignments. The answer is taken modulo .
5 2
54
7 4
1728
Hint
Constraints: For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号