結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー lloyzlloyz
提出日時 2023-06-05 00:11:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 409 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 78,380 KB
最終ジャッジ日時 2023-08-28 08:34:59
合計ジャッジ時間 3,313 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
76,072 KB
testcase_01 WA -
testcase_02 AC 82 ms
76,608 KB
testcase_03 AC 84 ms
77,576 KB
testcase_04 WA -
testcase_05 AC 86 ms
77,020 KB
testcase_06 AC 84 ms
77,592 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 79 ms
75,972 KB
testcase_11 AC 78 ms
76,388 KB
testcase_12 AC 77 ms
75,808 KB
testcase_13 WA -
testcase_14 AC 82 ms
77,880 KB
testcase_15 WA -
testcase_16 AC 80 ms
76,152 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 82 ms
75,808 KB
testcase_20 AC 76 ms
71,136 KB
testcase_21 AC 76 ms
70,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, p = map(int, input().split())
mod = 10**9 + 7

fact = [1] * (n + 1)
inv = [1] * (n + 1)
finv = [1] * (n + 1)
for i in range(2, n + 1):
    fact[i] = fact[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod
ans = 0
for i in range(1, n + 1):
    while i % p == 0:
        ans += 1
        i //= p
pp = pow(fact[n], fact[n], mod)
print(ans * pp % mod)
0