結果

問題 No.2211 Frequency Table of GCD
ユーザー nono00nono00
提出日時 2023-02-11 00:45:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,178 bytes
コンパイル時間 2,320 ms
コンパイル使用メモリ 202,164 KB
実行使用メモリ 5,696 KB
最終ジャッジ日時 2023-09-22 01:21:59
合計ジャッジ時間 5,233 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 21 ms
5,156 KB
testcase_04 AC 41 ms
4,648 KB
testcase_05 AC 59 ms
4,884 KB
testcase_06 AC 41 ms
4,964 KB
testcase_07 AC 59 ms
5,152 KB
testcase_08 AC 13 ms
4,380 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 26 ms
4,376 KB
testcase_11 AC 20 ms
4,376 KB
testcase_12 AC 28 ms
4,376 KB
testcase_13 AC 36 ms
4,876 KB
testcase_14 AC 39 ms
5,144 KB
testcase_15 AC 31 ms
5,164 KB
testcase_16 AC 38 ms
5,176 KB
testcase_17 AC 53 ms
4,824 KB
testcase_18 AC 79 ms
5,420 KB
testcase_19 AC 81 ms
5,416 KB
testcase_20 AC 80 ms
5,696 KB
testcase_21 AC 80 ms
5,424 KB
testcase_22 AC 81 ms
5,416 KB
testcase_23 AC 22 ms
5,380 KB
testcase_24 AC 77 ms
5,516 KB
testcase_25 AC 27 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 76 ms
5,508 KB
testcase_28 AC 78 ms
5,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define rrep(i, r, l) for (int i = (int)(r); i > (int)(l); i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

constexpr long long mod = 998244353;

namespace nono {

long long pow_mod(long long x, long long y, long long p) {
    long long result = 1;
    while (y > 0) {
        if ((y & 1) == 1) {
            result *= x;
            result %= p;
        }
        y >>= 1;
        x *= x;
        x %= p;
    }
    return result;
}

} // namespace nono

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> count(m + 1);
    vector<long long> ans(m + 1, 0);
    rep(i, 0, n) {
        int v;
        cin >> v;
        count[v]++;
    }

    rrep(i, m, 0) {
        int x = 0;
        for (int j = i; j <= m; j += i) {
            x += count[j];
            ans[i] += mod - ans[j];
        }
        ans[i] += nono::pow_mod(2, x, mod) - 1;
        ans[i] %= mod;
    }

    rep(i, 1, m + 1) {
        cout << ans[i] << '\n';
    }
}

int main() {
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
0