結果
問題 | No.2326 Factorial to the Power of Factorial to the... |
ユーザー | stunniita |
提出日時 | 2023-05-28 16:53:30 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 357 ms / 2,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 10,664 KB |
実行使用メモリ | 9,388 KB |
最終ジャッジ日時 | 2023-08-27 14:17:58 |
合計ジャッジ時間 | 4,844 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
8,252 KB |
testcase_01 | AC | 357 ms
9,388 KB |
testcase_02 | AC | 71 ms
8,412 KB |
testcase_03 | AC | 248 ms
9,004 KB |
testcase_04 | AC | 148 ms
8,848 KB |
testcase_05 | AC | 118 ms
8,636 KB |
testcase_06 | AC | 216 ms
9,168 KB |
testcase_07 | AC | 335 ms
9,352 KB |
testcase_08 | AC | 348 ms
9,284 KB |
testcase_09 | AC | 343 ms
9,280 KB |
testcase_10 | AC | 32 ms
8,428 KB |
testcase_11 | AC | 55 ms
8,420 KB |
testcase_12 | AC | 26 ms
7,908 KB |
testcase_13 | AC | 136 ms
8,780 KB |
testcase_14 | AC | 284 ms
9,240 KB |
testcase_15 | AC | 40 ms
7,892 KB |
testcase_16 | AC | 20 ms
7,960 KB |
testcase_17 | AC | 293 ms
9,108 KB |
testcase_18 | AC | 90 ms
8,728 KB |
testcase_19 | AC | 36 ms
8,288 KB |
testcase_20 | AC | 17 ms
7,964 KB |
testcase_21 | AC | 17 ms
8,024 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)