結果
| 問題 |
No.2326 Factorial to the Power of Factorial to the...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-29 21:02:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 337 bytes |
| コンパイル時間 | 346 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 60,800 KB |
| 最終ジャッジ日時 | 2024-12-28 10:18:00 |
| 合計ジャッジ時間 | 2,691 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 11 WA * 9 |
ソースコード
MOD = 10 ** 9 + 7
n, p = map(int, input().split())
fact = [1 for _ in range(n + 1)]
for x in range(2, n + 1):
fact[x] = (fact[x - 1] * 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(fact[n], fact[n], MOD - 1) % MOD
print(ans)