結果
| 問題 | No.2576 LCM Pattern | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-12-04 07:15:44 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 43 ms / 2,000 ms | 
| コード長 | 1,492 bytes | 
| コンパイル時間 | 459 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 52,864 KB | 
| 最終ジャッジ日時 | 2024-09-26 22:46:02 | 
| 合計ジャッジ時間 | 2,312 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
from math import gcd
def isp(n):
    if n == 2: return True
    if n == 1 or n % 2 == 0: return False
    m = n - 1;l = m & -m;s = l.bit_length() - 1;d = m // l
    for a in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:
        if a == n: continue
        x = pow(a, d, n);r = 0
        if x == 1: continue
        while x != m:
            x = pow(x, 2, n);r += 1
            if x == 1 or r == s: return False
    return True
def findf(n):
    if n % 2 == 0: return 2
    m = int(n ** 0.125) + 1
    for c in range(1, n):
        def f(y): return (y * y + c) % n
        y = k = 0;g = q = r = 1
        while g == 1:
            x = y
            while k < 3 * r // 4: y = f(y);k += 1
            while k < r and g == 1:
                ys = y
                for _ in range(min(m, r - k)): y = f(y);q = q * abs(x - y) % n
                g = gcd(q, n);k += m
            k = r;r *= 2
        if g == n:
            g = 1;y = ys
            while g == 1: y = f(y);g = gcd(abs(x - y), n)
        if g == n: continue
        if isp(g): return g
        elif isp(n // g): return n // g
        else: return findf(g)
def factorize(n):
    res = []
    while not isp(n) and n > 1:
        p = findf(n)
        e = 0
        while n % p == 0:n //= p;e += 1
        res.append((p, e))
    if n > 1: res.append((n, 1))
    res.sort()
    return res
n, m = map(int, input().split())
ans = 1
mod = 998244353
for p, e in factorize(m):
	ans *= pow(e + 1, n, mod) - pow(e, n, mod)
	ans %= mod
print(ans)
            
            
            
        