結果

問題 No.2211 Frequency Table of GCD
ユーザー V_MelvilleV_Melville
提出日時 2023-02-11 00:03:55
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 6,010 ms
コンパイル使用メモリ 308,996 KB
実行使用メモリ 7,292 KB
最終ジャッジ日時 2023-09-22 01:18:03
合計ジャッジ時間 8,700 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 19 ms
5,148 KB
testcase_04 AC 39 ms
5,444 KB
testcase_05 AC 57 ms
5,980 KB
testcase_06 AC 37 ms
5,460 KB
testcase_07 AC 56 ms
6,248 KB
testcase_08 AC 14 ms
4,376 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 27 ms
4,656 KB
testcase_11 AC 21 ms
4,376 KB
testcase_12 AC 30 ms
4,380 KB
testcase_13 AC 34 ms
5,444 KB
testcase_14 AC 36 ms
5,724 KB
testcase_15 AC 28 ms
5,400 KB
testcase_16 AC 35 ms
5,728 KB
testcase_17 AC 52 ms
6,048 KB
testcase_18 AC 77 ms
7,032 KB
testcase_19 AC 76 ms
7,040 KB
testcase_20 AC 76 ms
7,160 KB
testcase_21 AC 76 ms
7,292 KB
testcase_22 AC 76 ms
7,044 KB
testcase_23 AC 21 ms
5,484 KB
testcase_24 AC 78 ms
7,040 KB
testcase_25 AC 31 ms
4,780 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 76 ms
7,168 KB
testcase_28 AC 80 ms
6,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using mint = modint998244353;

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    vector<int> cnt(m+1);
    for (int x : a) {
        cnt[x]++;
    }
    
    vector<mint> pow2(n+1, 1);
    rep(i, n) pow2[i+1] = pow2[i]*2;
    
    vector<int> b(m+1);
    for (int i = 1; i <= m; ++i) {
        for (int j = i; j <= m; j += i) {
            b[i] += cnt[j];
        }
    }
    
    vector<mint> ans(m+1);
    for (int i = m; i >= 1; --i) {
        ans[i] = pow2[b[i]]-1;
        for (int j = i*2; j <= m; j += i) {
            ans[i] -= ans[j];
        }
    }
    
    for (int i = 1; i <= m; ++i) cout << ans[i].val() << '\n';
    
    return 0;
}
0