結果

問題 No.2576 LCM Pattern
ユーザー hiro1729hiro1729
提出日時 2023-12-04 07:15:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,468 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 210,260 KB
最終ジャッジ日時 2023-12-04 07:15:06
合計ジャッジ時間 4,309 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
60,264 KB
testcase_01 AC 37 ms
53,844 KB
testcase_02 AC 35 ms
53,844 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 36 ms
53,844 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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
for p, e in factorize(m):
	ans *= (e + 1) ** n - e ** n
	ans %= 998244353
print(ans)
0