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