結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー lloyzlloyz
提出日時 2023-06-05 00:13:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 376 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 77,836 KB
最終ジャッジ日時 2023-08-28 08:35:02
合計ジャッジ時間 3,160 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
75,976 KB
testcase_01 WA -
testcase_02 AC 78 ms
76,440 KB
testcase_03 AC 81 ms
77,116 KB
testcase_04 WA -
testcase_05 AC 76 ms
76,592 KB
testcase_06 AC 77 ms
77,092 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 74 ms
76,084 KB
testcase_11 AC 75 ms
76,476 KB
testcase_12 AC 75 ms
76,216 KB
testcase_13 WA -
testcase_14 AC 78 ms
77,352 KB
testcase_15 WA -
testcase_16 AC 74 ms
76,032 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 78 ms
76,000 KB
testcase_20 AC 71 ms
71,368 KB
testcase_21 AC 71 ms
71,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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