結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー lloyz
提出日時 2023-06-05 00:11:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 409 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,476 KB
実行使用メモリ 63,592 KB
最終ジャッジ日時 2024-12-29 04:03:47
合計ジャッジ時間 2,097 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

n, p = map(int, input().split())
mod = 10**9 + 7

fact = [1] * (n + 1)
inv = [1] * (n + 1)
finv = [1] * (n + 1)
for i in range(2, n + 1):
    fact[i] = fact[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod
ans = 0
for i in range(1, n + 1):
    while i % p == 0:
        ans += 1
        i //= p
pp = pow(fact[n], fact[n], mod)
print(ans * pp % mod)
0