結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー lloyzlloyz
提出日時 2023-06-05 00:14:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 1,086 ms
コンパイル使用メモリ 86,312 KB
実行使用メモリ 77,088 KB
最終ジャッジ日時 2023-08-28 08:35:07
合計ジャッジ時間 3,158 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,608 KB
testcase_01 AC 80 ms
77,088 KB
testcase_02 AC 78 ms
76,036 KB
testcase_03 AC 78 ms
76,572 KB
testcase_04 AC 79 ms
76,132 KB
testcase_05 AC 78 ms
76,052 KB
testcase_06 AC 77 ms
76,812 KB
testcase_07 AC 79 ms
77,016 KB
testcase_08 AC 80 ms
76,984 KB
testcase_09 AC 79 ms
76,904 KB
testcase_10 AC 76 ms
75,444 KB
testcase_11 AC 76 ms
75,712 KB
testcase_12 AC 79 ms
75,816 KB
testcase_13 AC 78 ms
76,132 KB
testcase_14 AC 79 ms
76,684 KB
testcase_15 AC 77 ms
75,832 KB
testcase_16 AC 77 ms
75,612 KB
testcase_17 AC 78 ms
77,016 KB
testcase_18 AC 77 ms
76,020 KB
testcase_19 AC 77 ms
75,808 KB
testcase_20 AC 72 ms
71,220 KB
testcase_21 AC 72 ms
70,972 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 - 1)
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