結果
| 問題 | 
                            No.2326 Factorial to the Power of Factorial to the...
                             | 
                    
| コンテスト | |
| ユーザー | 
                             094
                         | 
                    
| 提出日時 | 2023-05-28 16:48:10 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 241 ms / 2,000 ms | 
| コード長 | 294 bytes | 
| コンパイル時間 | 303 ms | 
| コンパイル使用メモリ | 82,248 KB | 
| 実行使用メモリ | 78,592 KB | 
| 最終ジャッジ日時 | 2024-12-27 11:57:23 | 
| 合計ジャッジ時間 | 4,225 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 20 | 
ソースコード
import math
MOD = 10**9 + 7
n, p = map(int, input().split())
nfact_cnt = 0
tmp = n
while tmp > 0:
	nfact_cnt += tmp // p
	tmp = tmp // p
fact = [1] * 101010
r = 1
for i in range(1, 101010):
    fact[i] = r = r * i % MOD
fc = math.factorial(n)
print(nfact_cnt * pow(fact[n], fc, MOD) % MOD)
            
            
            
        
            
094