結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー kemunikukemuniku
提出日時 2023-05-28 14:09:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 639 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,312 KB
実行使用メモリ 76,456 KB
最終ジャッジ日時 2023-08-27 09:08:13
合計ジャッジ時間 3,133 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
76,036 KB
testcase_01 WA -
testcase_02 AC 77 ms
75,752 KB
testcase_03 AC 78 ms
75,728 KB
testcase_04 WA -
testcase_05 AC 79 ms
76,112 KB
testcase_06 AC 78 ms
76,168 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 75 ms
76,164 KB
testcase_11 AC 77 ms
75,724 KB
testcase_12 AC 76 ms
76,208 KB
testcase_13 WA -
testcase_14 AC 77 ms
75,648 KB
testcase_15 WA -
testcase_16 AC 78 ms
75,612 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 76 ms
76,256 KB
testcase_20 AC 75 ms
71,516 KB
testcase_21 AC 74 ms
71,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def func(x,p):
    res = 0
    li = factorization(p)
    p = li[-1][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

print(func(N,P)*pow(tmp,tmp,MOD)%MOD)
0