結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー masa_aamasa_aa
提出日時 2023-05-28 14:30:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 237 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 76,132 KB
最終ジャッジ日時 2023-08-27 09:59:15
合計ジャッジ時間 3,343 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
76,036 KB
testcase_01 AC 77 ms
75,780 KB
testcase_02 AC 75 ms
76,116 KB
testcase_03 AC 80 ms
76,132 KB
testcase_04 AC 75 ms
76,048 KB
testcase_05 AC 75 ms
75,972 KB
testcase_06 AC 79 ms
76,024 KB
testcase_07 AC 77 ms
75,852 KB
testcase_08 AC 75 ms
76,072 KB
testcase_09 AC 78 ms
76,132 KB
testcase_10 AC 75 ms
75,832 KB
testcase_11 AC 77 ms
75,996 KB
testcase_12 AC 76 ms
75,684 KB
testcase_13 AC 75 ms
75,868 KB
testcase_14 AC 78 ms
75,964 KB
testcase_15 AC 76 ms
75,852 KB
testcase_16 AC 77 ms
75,984 KB
testcase_17 AC 77 ms
75,852 KB
testcase_18 AC 76 ms
75,908 KB
testcase_19 AC 75 ms
75,836 KB
testcase_20 AC 70 ms
71,372 KB
testcase_21 AC 73 ms
71,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, p = map(int, input().split())
k = 0
pp = p
while pp <= n:
    k += n // pp
    pp *= p
    
mod = 1_000_000_007
x = 1
y = 1
for i in range(1, n + 1):
    x *= i
    x %= mod
    y *= i
    y %= mod - 1
print(k * pow(x, y, mod) % mod)
0