結果
問題 | No.1529 Constant Lcm |
ユーザー |
![]() |
提出日時 | 2021-06-04 20:15:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 81 ms / 3,000 ms |
コード長 | 1,253 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 81,852 KB |
実行使用メモリ | 78,212 KB |
最終ジャッジ日時 | 2024-11-19 08:20:52 |
合計ジャッジ時間 | 2,709 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
import syssys.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 = 998244353def sieve_of_eratosthenes(n): # n以下の素数の全列挙prime_list = []is_prime = [1]*(n+1) # A[i] = iが素数なら1,その他は0is_prime[0] = is_prime[1] = 0for 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] = 0for i in range(int(n**.5)+1,n+1):if is_prime[i] == 1:prime_list.append(i)return prime_listprime_list = sieve_of_eratosthenes(N-1)ans = 1for p in prime_list:count = -1cur = 1while cur <= N-1:cur *= pcount += 1n = N-pow(p,count)while n % p == 0:n //= pcount += 1ans *= pow(p,count)ans %= mod# print(ans)print(ans)