結果
問題 | No.2211 Frequency Table of GCD |
ユーザー |
|
提出日時 | 2023-02-11 17:23:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 971 bytes |
コンパイル時間 | 1,683 ms |
コンパイル使用メモリ | 194,328 KB |
最終ジャッジ日時 | 2025-02-10 14:25:20 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;using pii=pair<int,int>;#define all(a) a.begin(),a.end()#define pb push_back#define sz(a) ((int)a.size())const int maxn=200005,mod=998244353;int add(int x, int y){x+=y; if(x>=mod) x-=mod; return x;}int sub(int x, int y){x-=y; if(x<0) x+=mod; return x;}int n,m,a[maxn],mu[maxn],pw2[maxn];signed main(){ios_base::sync_with_stdio(0),cin.tie(0);cin >> n >> m;for(int i=0; i<n; ++i){int x; cin >> x;a[x]++;}for(int i=1; i<=m; ++i) for(int j=i*2; j<=m; j+=i) a[i]+=a[j];mu[1]=1; for(int i=1; i<=m; ++i) for(int j=i*2; j<=m; j+=i) mu[j]-=mu[i];pw2[0]=1; for(int i=1; i<maxn; ++i) pw2[i]=pw2[i-1]*2%mod;for(int i=1; i<=m; ++i){int res=0;for(int j=1; i*j<=m; ++j){if(mu[j]==1) res=add(res,sub(pw2[a[i*j]],1));if(mu[j]==-1) res=sub(res,sub(pw2[a[i*j]],1));}cout << res << "\n";}}