結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー Today03Today03
提出日時 2024-03-16 12:31:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 317 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-03-16 12:31:19
合計ジャッジ時間 3,055 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
9,856 KB
testcase_01 AC 84 ms
9,856 KB
testcase_02 AC 45 ms
9,856 KB
testcase_03 AC 72 ms
9,856 KB
testcase_04 AC 58 ms
9,856 KB
testcase_05 AC 53 ms
9,856 KB
testcase_06 AC 85 ms
9,856 KB
testcase_07 AC 87 ms
9,856 KB
testcase_08 AC 85 ms
9,856 KB
testcase_09 AC 84 ms
9,856 KB
testcase_10 AC 34 ms
9,856 KB
testcase_11 AC 42 ms
9,856 KB
testcase_12 AC 33 ms
9,856 KB
testcase_13 AC 54 ms
9,856 KB
testcase_14 AC 79 ms
9,856 KB
testcase_15 AC 37 ms
9,856 KB
testcase_16 AC 33 ms
9,856 KB
testcase_17 AC 82 ms
9,856 KB
testcase_18 AC 49 ms
9,856 KB
testcase_19 AC 35 ms
9,856 KB
testcase_20 AC 29 ms
9,856 KB
testcase_21 AC 29 ms
9,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P = map(int, input().split())
MOD = 10**9 + 7

fact = 1
for i in range(1, N + 1):
    fact *= i
    fact %= MOD

fact2 = 1
for i in range(1, N + 1):
    fact2 *= i
    fact2 %= MOD - 1

val = pow(fact, fact2, MOD)

cnt, tmp = 0, P
while tmp <= N:
    cnt += N // tmp
    tmp *= P

ans = cnt * val % MOD
print(ans)
0