結果

問題 No.2211 Frequency Table of GCD
ユーザー ygd.ygd.
提出日時 2023-02-10 22:35:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,765 ms / 2,000 ms
コード長 1,715 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 131,832 KB
最終ジャッジ日時 2023-09-22 01:14:42
合計ジャッジ時間 17,862 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
97,572 KB
testcase_01 AC 126 ms
97,592 KB
testcase_02 AC 126 ms
97,432 KB
testcase_03 AC 228 ms
111,420 KB
testcase_04 AC 595 ms
122,852 KB
testcase_05 AC 812 ms
121,520 KB
testcase_06 AC 583 ms
117,336 KB
testcase_07 AC 848 ms
125,716 KB
testcase_08 AC 138 ms
107,316 KB
testcase_09 AC 137 ms
103,316 KB
testcase_10 AC 153 ms
119,404 KB
testcase_11 AC 144 ms
112,364 KB
testcase_12 AC 158 ms
122,304 KB
testcase_13 AC 522 ms
118,576 KB
testcase_14 AC 579 ms
114,692 KB
testcase_15 AC 439 ms
108,692 KB
testcase_16 AC 562 ms
114,508 KB
testcase_17 AC 770 ms
125,504 KB
testcase_18 AC 1,129 ms
126,908 KB
testcase_19 AC 1,312 ms
127,172 KB
testcase_20 AC 1,129 ms
126,836 KB
testcase_21 AC 1,145 ms
127,228 KB
testcase_22 AC 1,140 ms
127,076 KB
testcase_23 AC 192 ms
131,832 KB
testcase_24 AC 233 ms
127,112 KB
testcase_25 AC 159 ms
125,952 KB
testcase_26 AC 124 ms
97,592 KB
testcase_27 AC 1,765 ms
131,244 KB
testcase_28 AC 218 ms
127,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
import math
import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
from collections import defaultdict
from collections import deque
import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
MOD = 998244353
dx = [1,0,-1,0]
dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def make_divisors(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]

def main():
    N,M = map(int,input().split()); MAX = 3*pow(10,5)
    pow2 = [1]
    for i in range(MAX):
        pow2.append(pow2[-1]*2%MOD)
    A = list(map(int,input().split()))
    Adic = defaultdict(int)
    for a in A:
        Adic[a] += 1
    dic = defaultdict(int)
    for a,n in Adic.items():
        X = make_divisors(a)
        for x in X:
            dic[x] += n
    # print(dic)
    ans = [0]*(M+1)
    for i in reversed(range(1,M+1)):
        temp = pow2[dic[i]] - 1
        # print(i,temp)
        if temp == 0:
            ans[i] = temp
        else:
            for fac in range(2,MAX):
                if i*fac > M: break
                # print("XX",i*fac,ans[i*fac])
                temp -= ans[i*fac]
                temp %= MOD
            ans[i] = temp
    for i in range(1,M+1):
        print(ans[i]%MOD)
                


if __name__ == '__main__':
    main()
0