luogu#P5059. 中国象棋
中国象棋
Background
gjm really likes studying board game problems. Recently, he has been researching Chinese chess QwQ.
Problem Description
Now, in gjm’s mind there is an chessboard, with a total of cells. gjm starts placing pawns on the grid points of the board. It is known that a pawn only attacks pieces on the grid point one step to its left and one step to its right. Now gjm places any number of pawns on the board, satisfying:
- Each row has at least two pawns placed.
- No two pawns attack each other.
gjm now wants to know: how many pawn placement schemes satisfy the above conditions? Since the answer may be very large, you only need to output the number of schemes modulo .
Two schemes are considered different if and only if there exists at least one grid point where the placement differs.
Input Format
One line with two positive integers, and .
Output Format
One line with one integer, the number of pawn placement schemes on an board modulo .
1 10007
0
2 1000000000
1
7 1000000000
612231936
Hint
Explanation for Sample 1
Obviously, there is no valid scheme.
Explanation for Sample 2 ( means no pawn on the grid point, means there is a pawn on the grid point.)
There is only one scheme:
This sample and its explanation are correct.
Explanation for Sample 3
It is too large to list all schemes, so no explanation is given.
Constraints:
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
By: Endless Learning.
Translated by ChatGPT 5