結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー rlangevinrlangevin
提出日時 2023-05-29 23:09:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 247 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 75,872 KB
最終ジャッジ日時 2023-08-28 00:05:16
合計ジャッジ時間 3,415 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
75,612 KB
testcase_01 AC 83 ms
75,640 KB
testcase_02 AC 79 ms
75,508 KB
testcase_03 AC 79 ms
75,580 KB
testcase_04 AC 79 ms
75,872 KB
testcase_05 AC 82 ms
75,756 KB
testcase_06 AC 81 ms
75,352 KB
testcase_07 AC 81 ms
75,756 KB
testcase_08 AC 81 ms
75,552 KB
testcase_09 AC 79 ms
75,536 KB
testcase_10 AC 78 ms
75,608 KB
testcase_11 AC 79 ms
75,620 KB
testcase_12 AC 79 ms
75,788 KB
testcase_13 AC 79 ms
75,548 KB
testcase_14 AC 79 ms
75,856 KB
testcase_15 AC 78 ms
75,752 KB
testcase_16 AC 81 ms
75,612 KB
testcase_17 AC 82 ms
75,324 KB
testcase_18 AC 82 ms
75,512 KB
testcase_19 AC 82 ms
75,752 KB
testcase_20 AC 77 ms
71,156 KB
testcase_21 AC 77 ms
71,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P = map(int, input().split())
cnt = 0
now = P
while N // now:
    cnt += N // now
    now *= P
    
a, x = 1, 1
mod = 10**9 + 7
for i in range(1, N + 1):
    a *= i
    x *= i
    a %= mod
    x %= mod - 1
    
print(cnt * pow(a, x, mod) % mod)
0