結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー kemunikukemuniku
提出日時 2023-05-28 15:46:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 75,876 KB
最終ジャッジ日時 2023-08-27 12:55:50
合計ジャッジ時間 3,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,704 KB
testcase_01 AC 73 ms
75,528 KB
testcase_02 AC 73 ms
75,604 KB
testcase_03 AC 73 ms
75,788 KB
testcase_04 AC 73 ms
75,776 KB
testcase_05 AC 73 ms
75,816 KB
testcase_06 AC 75 ms
75,772 KB
testcase_07 AC 75 ms
75,768 KB
testcase_08 AC 74 ms
75,876 KB
testcase_09 AC 73 ms
75,744 KB
testcase_10 AC 74 ms
75,828 KB
testcase_11 AC 73 ms
75,604 KB
testcase_12 AC 73 ms
75,728 KB
testcase_13 AC 74 ms
75,784 KB
testcase_14 AC 75 ms
75,592 KB
testcase_15 AC 73 ms
75,764 KB
testcase_16 AC 73 ms
75,720 KB
testcase_17 AC 74 ms
75,752 KB
testcase_18 AC 73 ms
75,668 KB
testcase_19 AC 72 ms
75,872 KB
testcase_20 AC 68 ms
71,464 KB
testcase_21 AC 70 ms
71,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def func(x,p):
    res = 0
    y = p
    while x//y != 0:
        res += x//y
        y*=p
    return res
MOD = 10**9+7
N,P = map(int,input().split())
tmp = 1
for i in range(2,N+1):
    tmp = (tmp*i)%MOD
tmp2 = 1
for i in range(2,N+1):
    tmp2 = (tmp2*i)%(MOD-1)
print(func(N,P)*pow(tmp,tmp2,MOD)%MOD)
0