結果

問題 No.2211 Frequency Table of GCD
ユーザー ttkkggwwttkkggww
提出日時 2023-02-10 22:38:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 294 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 3,870 ms
コンパイル使用メモリ 259,916 KB
実行使用メモリ 7,444 KB
最終ジャッジ日時 2023-09-22 01:15:30
合計ジャッジ時間 10,909 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
6,916 KB
testcase_01 AC 19 ms
6,904 KB
testcase_02 AC 19 ms
6,908 KB
testcase_03 AC 255 ms
7,264 KB
testcase_04 AC 194 ms
7,180 KB
testcase_05 AC 223 ms
7,372 KB
testcase_06 AC 234 ms
7,324 KB
testcase_07 AC 264 ms
7,276 KB
testcase_08 AC 23 ms
6,908 KB
testcase_09 AC 21 ms
6,904 KB
testcase_10 AC 27 ms
6,908 KB
testcase_11 AC 25 ms
7,168 KB
testcase_12 AC 29 ms
7,028 KB
testcase_13 AC 187 ms
7,024 KB
testcase_14 AC 259 ms
7,284 KB
testcase_15 AC 242 ms
7,180 KB
testcase_16 AC 253 ms
7,216 KB
testcase_17 AC 223 ms
7,200 KB
testcase_18 AC 288 ms
7,328 KB
testcase_19 AC 291 ms
7,308 KB
testcase_20 AC 289 ms
7,296 KB
testcase_21 AC 288 ms
7,308 KB
testcase_22 AC 294 ms
7,328 KB
testcase_23 AC 271 ms
6,924 KB
testcase_24 AC 293 ms
6,916 KB
testcase_25 AC 29 ms
6,948 KB
testcase_26 AC 18 ms
6,892 KB
testcase_27 AC 289 ms
7,444 KB
testcase_28 AC 288 ms
6,908 KB
権限があれば一括ダウンロードができます

ソースコード

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[201010];
ll p2[201010];
ll pat[201010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	for(int i = 0;i<201000;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<=200000;i++) {
		for(j=i*2;j<=200000;j+=i) num[i]+=num[j];
		pat[i]=(p2[num[i]]+mo-1)%mo;
	}
	for(i=200000;i>=1;i--) {
		for(j=i*2;j<=200000;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