結果
問題 | No.2326 Factorial to the Power of Factorial to the... |
ユーザー |
![]() |
提出日時 | 2024-03-16 12:31:16 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 317 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-09-30 03:55:51 |
合計ジャッジ時間 | 2,226 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
N, P = map(int, input().split()) MOD = 10**9 + 7 fact = 1 for i in range(1, N + 1): fact *= i fact %= MOD fact2 = 1 for i in range(1, N + 1): fact2 *= i fact2 %= MOD - 1 val = pow(fact, fact2, MOD) cnt, tmp = 0, P while tmp <= N: cnt += N // tmp tmp *= P ans = cnt * val % MOD print(ans)