結果

問題 No.1529 Constant Lcm
ユーザー ayaoniayaoni
提出日時 2021-06-04 20:15:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 3,000 ms
コード長 1,253 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 89,460 KB
最終ジャッジ日時 2023-08-12 08:56:13
合計ジャッジ時間 3,953 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,788 KB
testcase_01 AC 76 ms
75,516 KB
testcase_02 AC 76 ms
71,292 KB
testcase_03 AC 70 ms
71,936 KB
testcase_04 AC 72 ms
71,832 KB
testcase_05 AC 69 ms
71,468 KB
testcase_06 AC 68 ms
71,856 KB
testcase_07 AC 70 ms
71,596 KB
testcase_08 AC 68 ms
71,660 KB
testcase_09 AC 69 ms
71,668 KB
testcase_10 AC 102 ms
87,956 KB
testcase_11 AC 89 ms
80,768 KB
testcase_12 AC 78 ms
77,224 KB
testcase_13 AC 104 ms
86,088 KB
testcase_14 AC 96 ms
82,756 KB
testcase_15 AC 94 ms
82,972 KB
testcase_16 AC 92 ms
81,656 KB
testcase_17 AC 86 ms
78,972 KB
testcase_18 AC 85 ms
79,160 KB
testcase_19 AC 92 ms
83,040 KB
testcase_20 AC 108 ms
89,184 KB
testcase_21 AC 104 ms
89,460 KB
testcase_22 AC 103 ms
89,336 KB
testcase_23 AC 103 ms
89,256 KB
testcase_24 AC 104 ms
89,408 KB
testcase_25 AC 105 ms
89,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
mod = 998244353


def sieve_of_eratosthenes(n):  # n以下の素数の全列挙
    prime_list = []
    is_prime = [1]*(n+1)  # A[i] = iが素数なら1,その他は0
    is_prime[0] = is_prime[1] = 0
    for i in range(2,int(n**.5)+1):
        if is_prime[i]:
            prime_list.append(i)
            for j in range(i**2,n+1,i):
                is_prime[j] = 0
    for i in range(int(n**.5)+1,n+1):
        if is_prime[i] == 1:
            prime_list.append(i)
    return prime_list


prime_list = sieve_of_eratosthenes(N-1)
ans = 1
for p in prime_list:
    count = -1
    cur = 1
    while cur <= N-1:
        cur *= p
        count += 1
    n = N-pow(p,count)
    while n % p == 0:
        n //= p
        count += 1

    ans *= pow(p,count)
    ans %= mod
    # print(ans)

print(ans)
0