結果
問題 | No.2326 Factorial to the Power of Factorial to the... |
ユーザー |
|
提出日時 | 2023-05-29 21:05:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 338 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 59,520 KB |
最終ジャッジ日時 | 2024-12-28 10:18:18 |
合計ジャッジ時間 | 2,300 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
MOD = 10 ** 9 + 7 n, p = map(int, input().split()) power = 1 base = 1 for x in range(2, n + 1): power = (power * x) % (MOD - 1) base = (base * x) % MOD dp = [0 for _ in range(n + 1)] for x in range(2, n + 1): cur = x while cur % p == 0: dp[x] += 1 cur //= p ans = sum(dp) % MOD * pow(base, power, MOD) % MOD print(ans)