結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー AyunaAyuna
提出日時 2023-05-28 15:58:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 437 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 88,468 KB
最終ジャッジ日時 2023-08-27 13:30:37
合計ジャッジ時間 3,978 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
75,952 KB
testcase_01 WA -
testcase_02 AC 101 ms
77,852 KB
testcase_03 AC 139 ms
85,088 KB
testcase_04 WA -
testcase_05 AC 115 ms
80,036 KB
testcase_06 AC 137 ms
83,912 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 90 ms
76,068 KB
testcase_11 AC 96 ms
76,660 KB
testcase_12 AC 86 ms
75,648 KB
testcase_13 WA -
testcase_14 AC 146 ms
86,780 KB
testcase_15 WA -
testcase_16 AC 83 ms
75,948 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 89 ms
75,932 KB
testcase_20 AC 74 ms
71,376 KB
testcase_21 AC 76 ms
71,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, p = map(int, input().split())
pcnt = 0
pnow = p
while pnow <= n:
    pcnt += n // pnow
    pnow *= p
mod = 10 ** 9 + 7

def bikkuri_pre(n):
    global bikkuri, irukkib
    bikkuri = [1]
    irukkib = [1]
    for i in range(1, n + 1):
        bikkuri.append((bikkuri[-1] * i) % mod)
    for i in range(1, n + 1):
        irukkib.append(pow(bikkuri[i], mod - 2, mod))

bikkuri_pre(n)
print(pcnt * pow(bikkuri[n], bikkuri[n], mod) % mod)
0