結果
問題 | No.2211 Frequency Table of GCD |
ユーザー |
|
提出日時 | 2023-02-11 00:03:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 890 bytes |
コンパイル時間 | 4,798 ms |
コンパイル使用メモリ | 309,340 KB |
実行使用メモリ | 7,296 KB |
最終ジャッジ日時 | 2024-07-07 18:11:33 |
合計ジャッジ時間 | 7,668 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#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;}