結果
問題 | No.2211 Frequency Table of GCD |
ユーザー | siman |
提出日時 | 2023-02-13 17:24:01 |
言語 | C++17(clang) (17.0.6 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 365 ms / 2,000 ms |
コード長 | 1,120 bytes |
コンパイル時間 | 7,666 ms |
コンパイル使用メモリ | 106,848 KB |
実行使用メモリ | 6,292 KB |
最終ジャッジ日時 | 2023-09-23 11:43:45 |
合計ジャッジ時間 | 9,007 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 258 ms
5,228 KB |
testcase_04 | AC | 221 ms
4,912 KB |
testcase_05 | AC | 269 ms
5,540 KB |
testcase_06 | AC | 260 ms
5,192 KB |
testcase_07 | AC | 307 ms
5,760 KB |
testcase_08 | AC | 17 ms
4,384 KB |
testcase_09 | AC | 13 ms
4,380 KB |
testcase_10 | AC | 36 ms
4,380 KB |
testcase_11 | AC | 27 ms
4,380 KB |
testcase_12 | AC | 39 ms
4,380 KB |
testcase_13 | AC | 208 ms
4,904 KB |
testcase_14 | AC | 279 ms
5,524 KB |
testcase_15 | AC | 257 ms
5,272 KB |
testcase_16 | AC | 273 ms
5,440 KB |
testcase_17 | AC | 264 ms
5,436 KB |
testcase_18 | AC | 365 ms
6,280 KB |
testcase_19 | AC | 361 ms
6,276 KB |
testcase_20 | AC | 361 ms
6,228 KB |
testcase_21 | AC | 362 ms
6,276 KB |
testcase_22 | AC | 363 ms
6,276 KB |
testcase_23 | AC | 278 ms
5,492 KB |
testcase_24 | AC | 342 ms
6,228 KB |
testcase_25 | AC | 35 ms
4,376 KB |
testcase_26 | AC | 1 ms
4,380 KB |
testcase_27 | AC | 339 ms
6,232 KB |
testcase_28 | AC | 345 ms
6,292 KB |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; const ll MOD = 998244353; ll mod_pow(ll x, ll n, ll mod = MOD) { ll res = 1; while (n > 0) { if (n & 1) { res = res * x % mod; } x = x * x % mod; n >>= 1; } return res; } int main() { int N, M; cin >> N >> M; int counter[M + 1]; memset(counter, 0, sizeof(counter)); vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; ++counter[A[i]]; } sort(A.begin(), A.end()); reverse(A.begin(), A.end()); vector<ll> ans(M + 1, 0); for (int a = M; a >= 1; --a) { ll cnt = 0; int v = a; while (v <= M) { cnt += counter[v]; v += a; } ll c = (mod_pow(2, cnt) - 1 + MOD) % MOD; v = 2 * a; while (v <= M) { c -= ans[v]; c = (c + MOD) % MOD; v += a; } ans[a] = c; } for (int m = 1; m <= M; ++m) { cout << ans[m] << endl; } return 0; }