結果

問題 No.2211 Frequency Table of GCD
ユーザー no wayno way
提出日時 2023-02-10 22:17:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 1,410 ms
コンパイル使用メモリ 168,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 18:05:19
合計ジャッジ時間 3,998 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=2e5+10;
int a[N],f[N];
int n,m,x;
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1ll*x*x%mod) if (y&1) ans=1ll*ans*x%mod;
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%d",&x); a[x]++;
	}
	for (int i=1;i<=m;i++){
		int sum=0;
		for (int j=1;j*i<=m;j++) sum+=a[j*i];
		f[i]=(ksm(2,sum)-1+mod)%mod;
	}
	for (int i=m;i>=1;i--){
		for (int j=2;j*i<=m;j++) f[i]=(f[i]-f[i*j]+mod)%mod;
	}
	for (int i=1;i<=m;i++) printf("%d\n",f[i]);
}
0