結果
| 問題 | No.2576 LCM Pattern | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-12-04 16:57:57 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 117 ms / 2,000 ms | 
| コード長 | 574 bytes | 
| コンパイル時間 | 713 ms | 
| コンパイル使用メモリ | 82,048 KB | 
| 実行使用メモリ | 76,416 KB | 
| 最終ジャッジ日時 | 2024-09-26 23:03:18 | 
| 合計ジャッジ時間 | 2,742 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
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)
            
            
            
        