結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー cozy_saunacozy_sauna
提出日時 2023-05-28 15:30:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 305 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 75,948 KB
最終ジャッジ日時 2023-08-27 12:17:53
合計ジャッジ時間 3,304 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,636 KB
testcase_01 AC 89 ms
75,628 KB
testcase_02 AC 80 ms
75,900 KB
testcase_03 AC 80 ms
75,612 KB
testcase_04 AC 79 ms
75,792 KB
testcase_05 AC 82 ms
75,820 KB
testcase_06 AC 80 ms
75,776 KB
testcase_07 AC 80 ms
75,616 KB
testcase_08 AC 80 ms
75,764 KB
testcase_09 AC 81 ms
75,668 KB
testcase_10 AC 81 ms
75,840 KB
testcase_11 AC 80 ms
75,832 KB
testcase_12 AC 79 ms
75,904 KB
testcase_13 AC 79 ms
75,832 KB
testcase_14 AC 79 ms
75,824 KB
testcase_15 AC 76 ms
75,628 KB
testcase_16 AC 78 ms
75,748 KB
testcase_17 AC 78 ms
75,844 KB
testcase_18 AC 77 ms
75,628 KB
testcase_19 AC 79 ms
75,948 KB
testcase_20 AC 74 ms
71,332 KB
testcase_21 AC 74 ms
70,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

N, P = map(int, input().split())

a = 0
k = 1
while 1:
    div = N // (P ** k)
    if div == 0: break
    a += div
    k += 1

b = 1
for i in range(1, N + 1):
    b *= i
    b %= MOD

c = 1
for i in range(1, N + 1):
    c *= i
    c %= MOD - 1

ans = a * pow(b, c, MOD) % MOD
print(ans)
0