結果

問題 No.2576 LCM Pattern
ユーザー nikoro256nikoro256
提出日時 2023-12-08 01:48:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 756 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 59,768 KB
最終ジャッジ日時 2023-12-08 01:48:58
合計ジャッジ時間 2,252 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,716 KB
testcase_01 AC 35 ms
53,716 KB
testcase_02 AC 36 ms
53,716 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 40 ms
59,768 KB
testcase_06 WA -
testcase_07 AC 37 ms
57,428 KB
testcase_08 AC 40 ms
59,768 KB
testcase_09 AC 40 ms
59,768 KB
testcase_10 WA -
testcase_11 AC 40 ms
59,768 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 38 ms
57,428 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 34 ms
53,716 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 exp(a,b,p):
    ans,mul,div=1,a,1
    for i in range(70):
        if b//div%2==1:
            ans*=mul
            ans%=p
        mul=mul**2%p
        div*=2
    return ans%p


N,M=map(int,input().split())
p=998244353
S=factorization(M)
ans=1
for a,b in S:
    dp=[0 for _ in range(b+1)]
    sub=0
    for i in range(b+1):
        dp[i]=exp(i+1,N,p)-sub
        sub+=dp[i]
    ans*=dp[-1]
print(ans)
0