結果
| 問題 | No.2326 Factorial to the Power of Factorial to the... |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-28 15:40:07 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 294 bytes |
| 記録 | |
| コンパイル時間 | 242 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 59,136 KB |
| 最終ジャッジ日時 | 2026-06-01 23:32:45 |
| 合計ジャッジ時間 | 2,157 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
n,p = map(int,input().split())
mod = 10**9+7
num = 0
facts = 1
fact2 = 1
for i in range(1,n+1):
now = i
while now%p == 0:
now //= p
num += 1
facts *= i
facts %= mod
fact2 *= i
fact2 %= mod-1
po = pow(facts,fact2,mod)
ans = num * po % mod
print(ans)