結果

問題 No.2211 Frequency Table of GCD
ユーザー shobonvipshobonvip
提出日時 2023-02-10 21:26:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,896 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 109,504 KB
最終ジャッジ日時 2023-09-22 00:57:34
合計ジャッジ時間 22,121 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,536 KB
testcase_01 AC 74 ms
71,148 KB
testcase_02 AC 74 ms
71,324 KB
testcase_03 AC 188 ms
86,392 KB
testcase_04 AC 595 ms
91,848 KB
testcase_05 AC 924 ms
101,908 KB
testcase_06 AC 551 ms
88,116 KB
testcase_07 AC 911 ms
99,168 KB
testcase_08 AC 126 ms
86,512 KB
testcase_09 AC 115 ms
82,548 KB
testcase_10 AC 174 ms
99,272 KB
testcase_11 AC 145 ms
91,700 KB
testcase_12 AC 184 ms
102,184 KB
testcase_13 AC 516 ms
88,384 KB
testcase_14 AC 531 ms
88,860 KB
testcase_15 AC 378 ms
87,780 KB
testcase_16 AC 504 ms
88,212 KB
testcase_17 AC 832 ms
98,552 KB
testcase_18 AC 1,336 ms
109,120 KB
testcase_19 AC 1,655 ms
109,072 KB
testcase_20 AC 1,334 ms
109,228 KB
testcase_21 AC 1,335 ms
109,340 KB
testcase_22 AC 1,368 ms
109,272 KB
testcase_23 AC 171 ms
86,604 KB
testcase_24 AC 1,896 ms
109,504 KB
testcase_25 AC 142 ms
105,000 KB
testcase_26 AC 74 ms
71,148 KB
testcase_27 AC 1,608 ms
109,240 KB
testcase_28 AC 1,889 ms
109,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def makediv(n):
	lower_divisors , upper_divisors = [], []
	i = 1
	while i*i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n//i)
		i += 1
	return lower_divisors + upper_divisors[::-1]


mod = 998244353
n,m = map(int,input().split())
a = list(map(int,input().split()))
c = [0] * (m + 1)

for i in range(n):
	for j in makediv(a[i]):
		c[j] += 1

dp = [0] * (m + 1)

for i in range(m,0,-1):
	dp[i] = pow(2, c[i], mod) - 1
	for j in range(2*i, m+1, i):
		if j % i == 0:
			dp[i] -= dp[j]
			dp[i] %= mod

print(*dp[1:],sep="\n")
0