結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー ああいい
提出日時 2023-06-01 09:41:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 275 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 58,240 KB
最終ジャッジ日時 2024-12-28 14:35:56
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N,P = map(int,input().split())
mod = 10 ** 9 + 7

ans = 0
p = P
while p <= N:
    ans += N // p
    p *= P

tmp = 1
for i in range(2,N + 1):
    tmp = tmp * i % mod
    #print(tmp)
for i in range(1,N + 1):
    tmp = pow(tmp,i,mod)
    #print(tmp)
print(ans * tmp % mod)
    
0