結果
問題 | No.2211 Frequency Table of GCD |
ユーザー |
|
提出日時 | 2023-02-10 22:11:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,224 ms / 2,000 ms |
コード長 | 1,236 bytes |
コンパイル時間 | 1,506 ms |
コンパイル使用メモリ | 171,264 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2024-07-07 18:03:40 |
合計ジャッジ時間 | 16,218 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using pll = pair<ll, ll>;#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)#define rep(i, n) drep(i, 0, n - 1)#define all(a) (a).begin(), (a).end()#define pb push_back#define fi first#define se secondconst ll MOD = 1000000007;const ll MOD2 = 998244353;const ll INF = 1LL << 60;const ll MAX_N = 2e5;ll pow_mod(ll x, ll n, ll mod){ll ret = 1;while(n > 0){if(n & 1) ret = (ret*x)%mod;x = x*x%mod;n >>=1;}return ret;}int main(){cin.tie(nullptr);ios::sync_with_stdio(false);ll n, m;cin >> n >> m;vector<ll> a(n);rep(i, n) cin >> a[i];vector<ll> cnt(m+1, 0);rep(i, n){for(ll j=1; j*j<=a[i]; j++){if(a[i]%j!=0) continue;if(j==a[i]/j){cnt[j]++;}else{cnt[j]++;cnt[a[i]/j]++;}}}vector<ll> ans(m+1, 0);for(ll i=m; i>=1; i--){ans[i] = pow_mod(2, cnt[i], MOD2)-1;for(ll j=2*i; j<=m; j+=i){ans[i] = (ans[i] - ans[j] + MOD2)%MOD2;}}for(ll i=1; i<=m; i++) cout << ans[i] << endl;}