結果

問題 No.2211 Frequency Table of GCD
ユーザー ttkkggwwttkkggww
提出日時 2023-02-10 22:38:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 768 bytes
コンパイル時間 4,456 ms
コンパイル使用メモリ 260,924 KB
実行使用メモリ 5,444 KB
最終ジャッジ日時 2023-09-21 23:48:29
合計ジャッジ時間 10,009 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,176 KB
testcase_01 AC 10 ms
5,252 KB
testcase_02 AC 10 ms
5,444 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 14 ms
5,308 KB
testcase_09 AC 13 ms
5,304 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 11 ms
5,248 KB
testcase_27 RE -
testcase_28 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

//借りました
//https://kmjp.hatenablog.jp/entry/2017/04/30/0930
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;

int N,A;
ll mo=998244353;

int num[101010];
ll p2[101010];
ll pat[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	for(int i = 0;i<101000;i++) p2[i+1]=p2[i]*2%mo;
	
	
	cin>>N >> k;
	for(int i = 0;i<N;i++){
		cin>>x;
		num[x]++;
	}
	for(i=1;i<=100000;i++) {
		for(j=i*2;j<=100000;j+=i) num[i]+=num[j];
		pat[i]=(p2[num[i]]+mo-1)%mo;
	}
	for(i=100000;i>=1;i--) {
		for(j=i*2;j<=100000;j+=i) pat[i]-=pat[j];
		pat[i]=(pat[i]%mo+mo)%mo;
	}
	for(int i = 1;i<=k;i++){
		cout<<pat[i]<<endl;
	}
}
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	solve();
}
0