結果
問題 | No.2211 Frequency Table of GCD |
ユーザー | milanis48663220 |
提出日時 | 2023-02-10 21:46:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 461 ms / 2,000 ms |
コード長 | 2,601 bytes |
コンパイル時間 | 1,195 ms |
コンパイル使用メモリ | 123,764 KB |
実行使用メモリ | 30,056 KB |
最終ジャッジ日時 | 2023-09-22 01:03:50 |
合計ジャッジ時間 | 12,321 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 161 ms
27,896 KB |
testcase_01 | AC | 149 ms
27,812 KB |
testcase_02 | AC | 158 ms
27,936 KB |
testcase_03 | AC | 399 ms
29,000 KB |
testcase_04 | AC | 331 ms
29,320 KB |
testcase_05 | AC | 380 ms
29,504 KB |
testcase_06 | AC | 388 ms
29,328 KB |
testcase_07 | AC | 407 ms
29,592 KB |
testcase_08 | AC | 170 ms
27,980 KB |
testcase_09 | AC | 158 ms
28,084 KB |
testcase_10 | AC | 186 ms
28,516 KB |
testcase_11 | AC | 166 ms
28,320 KB |
testcase_12 | AC | 178 ms
28,508 KB |
testcase_13 | AC | 339 ms
28,996 KB |
testcase_14 | AC | 391 ms
29,248 KB |
testcase_15 | AC | 395 ms
29,064 KB |
testcase_16 | AC | 407 ms
29,328 KB |
testcase_17 | AC | 359 ms
29,352 KB |
testcase_18 | AC | 461 ms
29,820 KB |
testcase_19 | AC | 441 ms
29,776 KB |
testcase_20 | AC | 434 ms
30,056 KB |
testcase_21 | AC | 449 ms
29,788 KB |
testcase_22 | AC | 442 ms
29,856 KB |
testcase_23 | AC | 412 ms
28,784 KB |
testcase_24 | AC | 444 ms
29,304 KB |
testcase_25 | AC | 162 ms
28,616 KB |
testcase_26 | AC | 152 ms
27,792 KB |
testcase_27 | AC | 435 ms
29,856 KB |
testcase_28 | AC | 447 ms
29,348 KB |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #include <atcoder/modint> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template<typename T> vector<vector<T>> vec2d(int n, int m, T v){ return vector<vector<T>>(n, vector<T>(m, v)); } template<typename T> vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){ return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v))); } template<typename T> void print_vector(vector<T> v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using mint = atcoder::modint998244353; ostream& operator<<(ostream& os, const mint& m){ os << m.val(); return os; } const int N = 200000; int meb[N+1]; vector<int> divs[N+1]; int cnt[N+1]; int cnt_mul[N+1]; mint pow2[N+1]; void init(){ vector<int> cur(N+1); pow2[0] = 1; for(int x = 1; x <= N; x++){ for(int i = 0; i*x <= N; i++){ divs[i*x].push_back(x); } cur[x] = x; meb[x] = 1; pow2[x] = pow2[x-1]*2; } for(int x = 2; x <= N; x++){ for(int i = 1; i*x <= N; i++){ int cnt = 0; while(cur[x*i]%x == 0){ cnt++; cur[x*i] /= x; } if(cnt >= 2){ meb[x*i] = 0; } if(cnt == 1) meb[x*i] *= -1; } } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; init(); int n, m; cin >> n >> m; vector<int> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; cnt[a[i]]++; } for(int x = 1; x <= N; x++){ for(int y: divs[x]){ cnt_mul[y]+=cnt[x]; } } vector<mint> ans(m+1); for(int x = 1; x <= m; x++){ int y = m/x; for(int z = 1; z*x <= m; z++){ ans[x] += meb[z]*(pow2[cnt_mul[x*z]]-1); } cout << ans[x] << endl; } }