結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー ああいいああいい
提出日時 2023-06-01 09:41:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 275 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 76,148 KB
最終ジャッジ日時 2023-08-28 01:53:36
合計ジャッジ時間 3,361 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
76,044 KB
testcase_01 AC 116 ms
75,988 KB
testcase_02 AC 85 ms
75,880 KB
testcase_03 AC 106 ms
76,032 KB
testcase_04 AC 97 ms
75,908 KB
testcase_05 AC 94 ms
75,720 KB
testcase_06 AC 102 ms
75,956 KB
testcase_07 AC 115 ms
75,716 KB
testcase_08 AC 116 ms
75,848 KB
testcase_09 AC 114 ms
75,984 KB
testcase_10 AC 81 ms
75,944 KB
testcase_11 AC 81 ms
76,080 KB
testcase_12 AC 78 ms
76,148 KB
testcase_13 AC 93 ms
75,940 KB
testcase_14 AC 109 ms
76,064 KB
testcase_15 AC 80 ms
76,056 KB
testcase_16 AC 76 ms
75,944 KB
testcase_17 AC 110 ms
76,048 KB
testcase_18 AC 88 ms
75,908 KB
testcase_19 AC 80 ms
75,908 KB
testcase_20 AC 73 ms
71,240 KB
testcase_21 AC 71 ms
71,276 KB
権限があれば一括ダウンロードができます

ソースコード

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