結果

問題 No.2211 Frequency Table of GCD
ユーザー i_am_noobi_am_noob
提出日時 2023-02-11 17:23:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 971 bytes
コンパイル時間 2,092 ms
コンパイル使用メモリ 199,788 KB
実行使用メモリ 5,880 KB
最終ジャッジ日時 2023-09-22 13:50:13
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 27 ms
5,656 KB
testcase_04 AC 28 ms
5,224 KB
testcase_05 AC 37 ms
5,344 KB
testcase_06 AC 32 ms
5,724 KB
testcase_07 AC 40 ms
5,880 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 12 ms
4,440 KB
testcase_11 AC 10 ms
4,380 KB
testcase_12 AC 13 ms
4,376 KB
testcase_13 AC 27 ms
5,124 KB
testcase_14 AC 34 ms
5,584 KB
testcase_15 AC 30 ms
5,476 KB
testcase_16 AC 32 ms
5,520 KB
testcase_17 AC 35 ms
5,552 KB
testcase_18 AC 49 ms
5,856 KB
testcase_19 AC 49 ms
5,712 KB
testcase_20 AC 50 ms
5,684 KB
testcase_21 AC 49 ms
5,776 KB
testcase_22 AC 50 ms
5,724 KB
testcase_23 AC 29 ms
5,528 KB
testcase_24 AC 46 ms
5,300 KB
testcase_25 AC 13 ms
4,392 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 46 ms
5,688 KB
testcase_28 AC 46 ms
5,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
    }
}
0