結果
問題 | No.2326 Factorial to the Power of Factorial to the... |
ユーザー |
|
提出日時 | 2023-05-28 14:55:47 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 419 bytes |
コンパイル時間 | 566 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-12-27 03:34:47 |
合計ジャッジ時間 | 2,235 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
import sys def input(): return sys.stdin.readline().rstrip() def main(): N, P = map(int, input().split()) mod = 10**9+7 p = 1 q = 1 ans = 0 for i in range(1, N+1): p *= i p %= mod q *= i q %= (mod-1) a = i while not a%P: a //= P ans += 1 p = pow(p, q, mod) print(p*ans%mod) if __name__ == "__main__": main()