結果

問題 No.2211 Frequency Table of GCD
ユーザー ぷらぷら
提出日時 2023-02-10 21:43:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 2,059 ms
コンパイル使用メモリ 199,852 KB
実行使用メモリ 6,268 KB
最終ジャッジ日時 2023-09-22 01:01:31
合計ジャッジ時間 4,987 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 22 ms
4,540 KB
testcase_04 AC 25 ms
4,948 KB
testcase_05 AC 34 ms
5,468 KB
testcase_06 AC 28 ms
4,852 KB
testcase_07 AC 37 ms
5,360 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 12 ms
4,520 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 13 ms
4,376 KB
testcase_13 AC 24 ms
4,564 KB
testcase_14 AC 29 ms
4,952 KB
testcase_15 AC 25 ms
4,676 KB
testcase_16 AC 28 ms
4,812 KB
testcase_17 AC 32 ms
5,060 KB
testcase_18 AC 51 ms
6,204 KB
testcase_19 AC 49 ms
6,156 KB
testcase_20 AC 47 ms
6,212 KB
testcase_21 AC 47 ms
6,244 KB
testcase_22 AC 47 ms
6,252 KB
testcase_23 AC 24 ms
4,684 KB
testcase_24 AC 43 ms
6,244 KB
testcase_25 AC 13 ms
4,604 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 43 ms
6,268 KB
testcase_28 AC 43 ms
6,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int mod = 998244353;

void mpl(int &x,int y) {
    x += y;
    if(x >= mod) x -= mod;
}

int f[200200];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<int>A(N),B(M+1);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        B[A[i]]++;
    }
    f[0] = 1;
    for(int i = 1; i <= N; i++) {
        f[i] = f[i-1]*2%mod;
    }
    vector<int>ans(M+1);
    for(int i = M; i >= 1; i--) {
        int cnt = 0;
        for(int j = 1; i*j <= M; j++) {
            cnt += B[i*j];
        }
        ans[i] = (f[cnt]+mod-1)%mod;
        for(int j = 2; i*j <= M; j++) {
            mpl(ans[i],mod-ans[i*j]);
        }
    }
    for(int i = 1; i <= M; i++) {
        cout << ans[i] << "\n";
    }
}
0