結果

問題 No.2576 LCM Pattern
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-12-04 16:57:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2023-12-04 16:58:00
合計ジャッジ時間 2,439 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,460 KB
testcase_01 AC 43 ms
55,612 KB
testcase_02 AC 49 ms
61,840 KB
testcase_03 AC 42 ms
53,460 KB
testcase_04 AC 42 ms
53,460 KB
testcase_05 AC 53 ms
64,204 KB
testcase_06 AC 57 ms
64,204 KB
testcase_07 AC 47 ms
61,720 KB
testcase_08 AC 57 ms
64,204 KB
testcase_09 AC 50 ms
61,720 KB
testcase_10 AC 76 ms
70,644 KB
testcase_11 AC 58 ms
64,204 KB
testcase_12 AC 102 ms
76,288 KB
testcase_13 AC 66 ms
68,608 KB
testcase_14 AC 77 ms
72,732 KB
testcase_15 AC 48 ms
61,720 KB
testcase_16 AC 43 ms
55,612 KB
testcase_17 AC 49 ms
61,720 KB
testcase_18 AC 49 ms
61,720 KB
testcase_19 AC 50 ms
61,720 KB
testcase_20 AC 49 ms
61,720 KB
testcase_21 AC 45 ms
59,576 KB
testcase_22 AC 41 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
MOD=998244353
N,M=map(int,input().split())
use=set()
for i in range(1,M+1):
    if M%i==0:
        use.add(i)
        use.add(M//i)
    if i*i>M:
        break
use=sorted(list(use),reverse=True)
count=defaultdict(int)
count[M]=1
ans=0
for i in use:
    now=set()
    for j in range(1,i+1):
        if i%j==0:
            now.add(j)
            now.add(i//j)
        if j*j>i:
            break
    ans+=count[i]*pow(len(now),N,MOD)
    ans%=MOD
    for j in now:
        if j==i:
            continue
        count[j]-=count[i]
print(ans)
0