結果

問題 No.2576 LCM Pattern
ユーザー lloyzlloyz
提出日時 2023-12-15 01:14:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 59,404 KB
最終ジャッジ日時 2024-09-27 05:53:18
合計ジャッジ時間 2,162 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n, m = map(int, input().split())
mod = 998244353

PC = defaultdict(int)
cnt = 0
while m % 2 == 0:
    m //= 2
    cnt += 1
if cnt > 0:
    PC[2] = cnt
f = 3
while f * f <= m:
    cnt = 0
    while m % f == 0:
        m //= f
        cnt += 1
    if cnt > 0:
        PC[f] = cnt
    f += 2
if m > 1:
    PC[m] = 1
ans = 1
for val in PC.values():
    ans *= (pow(val + 1, n, mod) - pow(val, n, mod)) % mod
    ans %= mod
print(ans)
0