結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー 094094
提出日時 2023-05-28 15:14:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 80,220 KB
最終ジャッジ日時 2023-08-27 11:42:18
合計ジャッジ時間 4,428 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
77,072 KB
testcase_01 AC 233 ms
80,220 KB
testcase_02 AC 104 ms
77,560 KB
testcase_03 AC 176 ms
78,488 KB
testcase_04 AC 138 ms
78,020 KB
testcase_05 AC 120 ms
77,492 KB
testcase_06 AC 164 ms
78,468 KB
testcase_07 AC 223 ms
79,612 KB
testcase_08 AC 225 ms
79,716 KB
testcase_09 AC 224 ms
79,960 KB
testcase_10 AC 88 ms
77,552 KB
testcase_11 AC 97 ms
77,440 KB
testcase_12 AC 83 ms
76,916 KB
testcase_13 AC 131 ms
77,516 KB
testcase_14 AC 195 ms
78,956 KB
testcase_15 AC 91 ms
77,304 KB
testcase_16 AC 81 ms
76,852 KB
testcase_17 AC 205 ms
79,276 KB
testcase_18 AC 112 ms
77,568 KB
testcase_19 AC 89 ms
77,316 KB
testcase_20 AC 76 ms
76,640 KB
testcase_21 AC 79 ms
76,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n, p = map(int, input().split())
nfact_cnt = 0
tmp = n


while tmp > 0:
	nfact_cnt += tmp // p
	tmp = tmp // p

MOD = 10**9 + 7
N = 10**5 + 1010

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

nfact = fact[n]

#print(nfact_cnt, pow(nfact, nfact, MOD))
#print(nfact_cnt * pow(nfact, nfact, MOD) % MOD)

fc = math.factorial(n)
#print("===")

#print(nfact_cnt, pow(nfact, fc, MOD) % MOD)
print(nfact_cnt * pow(nfact, fc, MOD) % MOD)
0