結果

問題 No.2211 Frequency Table of GCD
ユーザー maksimmaksim
提出日時 2023-02-10 21:27:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 164,024 KB
実行使用メモリ 9,952 KB
最終ジャッジ日時 2023-09-22 00:57:39
合計ジャッジ時間 4,096 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,452 KB
testcase_01 AC 15 ms
7,432 KB
testcase_02 AC 15 ms
7,452 KB
testcase_03 AC 25 ms
7,936 KB
testcase_04 AC 33 ms
8,224 KB
testcase_05 AC 40 ms
9,024 KB
testcase_06 AC 32 ms
8,324 KB
testcase_07 AC 41 ms
9,220 KB
testcase_08 AC 20 ms
8,076 KB
testcase_09 AC 18 ms
7,848 KB
testcase_10 AC 25 ms
8,628 KB
testcase_11 AC 23 ms
8,332 KB
testcase_12 AC 27 ms
8,764 KB
testcase_13 AC 29 ms
8,268 KB
testcase_14 AC 32 ms
8,472 KB
testcase_15 AC 29 ms
8,124 KB
testcase_16 AC 32 ms
8,328 KB
testcase_17 AC 38 ms
8,720 KB
testcase_18 AC 49 ms
9,808 KB
testcase_19 AC 48 ms
9,616 KB
testcase_20 AC 49 ms
9,808 KB
testcase_21 AC 49 ms
9,660 KB
testcase_22 AC 49 ms
9,952 KB
testcase_23 AC 26 ms
6,496 KB
testcase_24 AC 45 ms
8,056 KB
testcase_25 AC 27 ms
9,072 KB
testcase_26 AC 15 ms
7,500 KB
testcase_27 AC 46 ms
9,664 KB
testcase_28 AC 44 ms
9,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int maxn=2e5+5;
const int p=998244353;
int cnt[maxn];int h[maxn];int po2[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    po2[0]=1;for(int i=1;i<maxn;++i) po2[i]=(po2[i-1]*2)%p;
    int n,m;cin>>n>>m;int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];cnt[a[i]]++;
    }
    for(int i=1;i<maxn;++i)
    {
        for(int j=i;j<maxn;j+=i)
        {
            h[i]+=cnt[j];
        }
        h[i]=po2[h[i]]-1;
    }
    for(int i=maxn-1;i>=1;--i)
    {
        for(int j=2*i;j<maxn;j+=i)
        {
            h[i]-=h[j];h[i]%=p;
        }
    }
    for(int i=1;i<=m;++i)
    {
        cout<<(h[i]%p+p)%p<<'\n';
    }
    return 0;
}
0