結果

問題 No.2211 Frequency Table of GCD
ユーザー otoshigootoshigo
提出日時 2023-02-10 21:58:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 387 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 201,796 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-09-22 01:06:57
合計ジャッジ時間 7,528 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 28 ms
5,140 KB
testcase_04 AC 113 ms
5,612 KB
testcase_05 AC 183 ms
6,452 KB
testcase_06 AC 104 ms
5,876 KB
testcase_07 AC 182 ms
6,720 KB
testcase_08 AC 10 ms
4,380 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 22 ms
4,980 KB
testcase_11 AC 15 ms
4,512 KB
testcase_12 AC 23 ms
4,836 KB
testcase_13 AC 95 ms
5,380 KB
testcase_14 AC 100 ms
5,960 KB
testcase_15 AC 69 ms
5,348 KB
testcase_16 AC 93 ms
5,924 KB
testcase_17 AC 164 ms
6,404 KB
testcase_18 AC 275 ms
7,784 KB
testcase_19 AC 273 ms
7,776 KB
testcase_20 AC 274 ms
7,732 KB
testcase_21 AC 275 ms
7,728 KB
testcase_22 AC 274 ms
7,940 KB
testcase_23 AC 28 ms
5,408 KB
testcase_24 AC 387 ms
7,732 KB
testcase_25 AC 16 ms
5,396 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 271 ms
7,856 KB
testcase_28 AC 387 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

const ll MOD=998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vector<ll>P(n+1);
    P[0]=1;
    rep(i,n)P[i+1]=2*P[i]%MOD;
    vector<int>a(n),c(m+1);
    rep(i,n){
        cin>>a[i];
        int b=1;
        while(b*b<=a[i]){
            if(a[i]%b==0){
                c[b]++;
                if(b*b<a[i])c[a[i]/b]++;
            }
            b++;
        }
    }
    vector<ll>ans(m+1);
    for(int i=m;i>=1;i--){
        ans[i]=P[c[i]]-1;
        for(int j=2*i;j<=m;j+=i){
            ans[i]-=ans[j];
            ans[i]%=MOD;
            if(ans[i]<0)ans[i]+=MOD;
        }
    }
    for(int i=1;i<=m;i++)cout<<ans[i]<<"\n";
}
0