結果
問題 | No.2326 Factorial to the Power of Factorial to the... |
ユーザー |
|
提出日時 | 2023-05-28 16:53:30 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 397 ms / 2,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 133 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-06-08 09:51:59 |
合計ジャッジ時間 | 4,763 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
10,880 KB |
testcase_01 | AC | 397 ms
11,648 KB |
testcase_02 | AC | 93 ms
11,008 KB |
testcase_03 | AC | 281 ms
11,520 KB |
testcase_04 | AC | 174 ms
11,264 KB |
testcase_05 | AC | 143 ms
11,136 KB |
testcase_06 | AC | 244 ms
11,392 KB |
testcase_07 | AC | 369 ms
11,776 KB |
testcase_08 | AC | 377 ms
11,776 KB |
testcase_09 | AC | 379 ms
11,776 KB |
testcase_10 | AC | 49 ms
10,752 KB |
testcase_11 | AC | 75 ms
10,752 KB |
testcase_12 | AC | 42 ms
10,752 KB |
testcase_13 | AC | 160 ms
11,264 KB |
testcase_14 | AC | 317 ms
11,776 KB |
testcase_15 | AC | 57 ms
10,880 KB |
testcase_16 | AC | 35 ms
10,752 KB |
testcase_17 | AC | 331 ms
11,648 KB |
testcase_18 | AC | 113 ms
11,136 KB |
testcase_19 | AC | 53 ms
10,880 KB |
testcase_20 | AC | 30 ms
10,880 KB |
testcase_21 | AC | 30 ms
10,752 KB |
ソースコード
import math MOD = 10 ** 9 + 7 N,P = map(int, input().split()) # るしゃんどる fst = 0 fst_p = P while True: x = N // fst_p if x == 0:break fst += x fst_p *= P #print(f"{fst=}") # N! mod P snd = 1 for i in range(1,N+1): snd *= i snd %= MOD if snd == 0: snd = MOD #print(f"{snd=}") thd = math.factorial(N) #print(f"{thd=}") ans = fst * pow(snd,thd,MOD) print(ans % MOD)