結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー googol_S0googol_S0
提出日時 2023-05-28 13:40:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 242 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 75,984 KB
最終ジャッジ日時 2023-08-27 08:14:04
合計ジャッジ時間 3,284 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,448 KB
testcase_01 AC 78 ms
75,812 KB
testcase_02 AC 71 ms
71,288 KB
testcase_03 AC 69 ms
71,164 KB
testcase_04 AC 78 ms
75,872 KB
testcase_05 AC 69 ms
71,324 KB
testcase_06 AC 70 ms
71,320 KB
testcase_07 AC 74 ms
75,888 KB
testcase_08 AC 76 ms
75,912 KB
testcase_09 AC 77 ms
75,800 KB
testcase_10 AC 73 ms
71,280 KB
testcase_11 AC 71 ms
71,124 KB
testcase_12 AC 71 ms
71,364 KB
testcase_13 AC 75 ms
75,984 KB
testcase_14 AC 70 ms
71,412 KB
testcase_15 AC 74 ms
75,960 KB
testcase_16 AC 72 ms
71,296 KB
testcase_17 AC 75 ms
75,792 KB
testcase_18 AC 76 ms
75,932 KB
testcase_19 AC 72 ms
71,484 KB
testcase_20 AC 72 ms
71,296 KB
testcase_21 AC 73 ms
71,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
N,P=map(int,input().split())
if N<P:
    print(0)
else:
    C=0
    p=P
    while p<=N:
        C+=N//p
        p*=P
    V=1
    W=1
    for i in range(1,N+1):
        V=V*i%mod
        W=W*i%(mod-1)
    print(C*pow(V,W,mod)%mod)
0