Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 1600 点
問題文
X = 10^{100} とします。イナバは N 個の駒を数直線上に置いていて、i 個目の駒は座標 X^{i} にあります。
1 秒ごとに、イナバは 2 個の駒 A、B を選び、A を B に関して対称な点に動かし、その後 B を取り除きます(A、B が同じ位置にあっても構わず、A が移動後に他の駒と同じ位置にあっても構いません)。
N - 1 秒後には、駒が 1 個だけ残ります。その駒の位置としてありうるものは何通りあるか、その数を 10^{9} + 7 で割った余りを求めてください。
制約
- 1 \leq N \leq 50
- N は整数である。
入力
入力は標準入力から以下の形式で与えられる。
N
出力
最後に残る駒の位置としてありうるものの数を 10^{9} + 7 で割った余りを出力せよ。
入力例 1
3
出力例 1
12
駒が 3 個あり、それぞれ座標 10^{100}, 10^{200}, 10^{300} に置かれています。これらをそれぞれ A、B、C と呼びます。
考えられる駒の動かし方(12 通り)のうち 2 つを示します。
-
最初の 1 秒で A に B を飛び越えさせ、次の 1 秒で A に C を飛び越えさせる。A の最終的な位置は 2 \times 10^{300} - 2 \times 10^{200} + 10^{100} となる。
-
最初の 1 秒で C に A を飛び越えさせ、次の 1 秒で B に C を飛び越えさせる。B の最終的な位置は -2 \times 10^{300} - 10^{200} + 4 \times 10^{100} となる。
駒の動かし方は合計で 3 \times 2 \times 2 = 12 通りあり、そのすべてで最後の駒は異なる位置に残ります。
入力例 2
4
出力例 2
84
入力例 3
22
出力例 3
487772376
答えを 10^{9} + 7 で割った余りを出力することを忘れずに。
Score : 1600 points
Problem Statement
Let X = 10^{100}. Inaba has N checker pieces on the number line, where the i-th checker piece is at coordinate X^{i} for all 1 \leq i \leq N.
Every second, Inaba chooses two checker pieces, A and B, and move A to the symmetric point of its current position with respect to B. After that, B is removed. (It is possible that A and B occupy the same position, and it is also possible for A to occupy the same position as another checker piece after the move).
After N - 1 seconds, only one checker piece will remain. Find the number of distinct possible positions of that checker piece, modulo 10^{9} + 7.
Constraints
- 1 \leq N \leq 50
- N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
Print the number of distinct possible positions of the final checker piece, modulo 10^{9} + 7.
Sample Input 1
3
Sample Output 1
12
There are 3 checker pieces, positioned at 10^{100}, 10^{200}, 10^{300} respectively. Call them A, B, C respectively.
Here are two (of the 12) possible sequence of moves :
-
Let A jump over B in the first second, and let A jump over C in the second second. The final position of A is 2 \times 10^{300} - 2 \times 10^{200} + 10^{100}.
-
Let C jump over A in the first second, and let B jump over C in the second second. The final position of B is -2 \times 10^{300} - 10^{200} + 4 \times 10^{100}.
There are a total of 3 \times 2 \times 2 = 12 possible sequence of moves, and the final piece are in different positions in all of them.
Sample Input 2
4
Sample Output 2
84
Sample Input 3
22
Sample Output 3
487772376
Remember to output your answer modulo 10^{9} + 7.