結果
問題 |
No.1263 ご注文は数学ですか?
|
ユーザー |
![]() |
提出日時 | 2025-04-16 01:01:06 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 854 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 82,164 KB |
実行使用メモリ | 54,076 KB |
最終ジャッジ日時 | 2025-04-16 01:02:28 |
合計ジャッジ時間 | 832 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 WA * 5 |
ソースコード
MOD = 10**9 + 7 # Stirling numbers of the first kind S(x, m) stirling = [ [], [0, 1], [0, 1, 1], [0, 2, 3, 1], [0, 6, 11, 6, 1], [0, 24, 50, 35, 10, 1], [0, 120, 274, 225, 85, 15, 1], [0, 720, 1764, 1624, 735, 175, 21, 1], [0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1], ] # Partition numbers p(x, m) for x from 0 to 8 partitions = [ [], [0, 1], [0, 1, 1], [0, 1, 1, 1], [0, 1, 2, 1, 1], [0, 1, 2, 2, 1, 1], [0, 1, 3, 3, 2, 1, 1], [0, 1, 3, 4, 3, 2, 1, 1], [0, 1, 4, 5, 5, 3, 2, 1, 1], ] x = int(input()) result = 1 for m in range(1, x + 1): p = partitions[x][m] if p == 0: continue sign = (-1) ** (x - m) s = stirling[x][m] base = sign * s base_mod = base % MOD term = pow(base_mod, p, MOD) result = (result * term) % MOD print(result)