結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー AyunaAyuna
提出日時 2023-05-28 16:46:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 88,484 KB
最終ジャッジ日時 2023-08-27 14:12:09
合計ジャッジ時間 3,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,772 KB
testcase_01 AC 180 ms
88,484 KB
testcase_02 AC 100 ms
77,488 KB
testcase_03 AC 160 ms
85,088 KB
testcase_04 AC 128 ms
81,052 KB
testcase_05 AC 119 ms
79,816 KB
testcase_06 AC 153 ms
83,996 KB
testcase_07 AC 183 ms
88,416 KB
testcase_08 AC 181 ms
88,296 KB
testcase_09 AC 181 ms
88,276 KB
testcase_10 AC 82 ms
76,080 KB
testcase_11 AC 92 ms
76,680 KB
testcase_12 AC 81 ms
75,720 KB
testcase_13 AC 124 ms
81,088 KB
testcase_14 AC 161 ms
86,608 KB
testcase_15 AC 92 ms
75,852 KB
testcase_16 AC 74 ms
75,964 KB
testcase_17 AC 164 ms
86,536 KB
testcase_18 AC 106 ms
78,772 KB
testcase_19 AC 81 ms
75,856 KB
testcase_20 AC 65 ms
71,056 KB
testcase_21 AC 65 ms
71,088 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)
a = bikkuri[n]
for i in range(1, n + 1):
    a = pow(a, i, mod)
print(pcnt * a % mod)
0