結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー cozy_saunacozy_sauna
提出日時 2023-05-28 15:28:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 326 bytes
コンパイル時間 811 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 75,944 KB
最終ジャッジ日時 2023-08-27 12:15:02
合計ジャッジ時間 3,455 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
75,836 KB
testcase_01 WA -
testcase_02 AC 79 ms
75,540 KB
testcase_03 AC 81 ms
75,924 KB
testcase_04 WA -
testcase_05 AC 79 ms
75,648 KB
testcase_06 AC 80 ms
75,772 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 80 ms
75,784 KB
testcase_11 AC 82 ms
75,900 KB
testcase_12 AC 82 ms
75,788 KB
testcase_13 WA -
testcase_14 AC 82 ms
75,896 KB
testcase_15 WA -
testcase_16 AC 82 ms
75,788 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 81 ms
75,672 KB
testcase_20 AC 76 ms
71,336 KB
testcase_21 AC 77 ms
71,120 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 - 1

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

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