結果

問題 No.2211 Frequency Table of GCD
ユーザー umimelumimel
提出日時 2023-02-10 22:11:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,302 ms / 2,000 ms
コード長 1,236 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 167,024 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2023-09-22 01:10:04
合計ジャッジ時間 17,237 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 256 ms
5,880 KB
testcase_04 AC 452 ms
5,936 KB
testcase_05 AC 659 ms
6,384 KB
testcase_06 AC 452 ms
6,112 KB
testcase_07 AC 690 ms
6,908 KB
testcase_08 AC 13 ms
4,380 KB
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 29 ms
4,376 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 32 ms
4,376 KB
testcase_13 AC 390 ms
5,616 KB
testcase_14 AC 459 ms
6,412 KB
testcase_15 AC 357 ms
5,804 KB
testcase_16 AC 437 ms
6,208 KB
testcase_17 AC 607 ms
6,536 KB
testcase_18 AC 981 ms
7,784 KB
testcase_19 AC 972 ms
7,696 KB
testcase_20 AC 979 ms
7,832 KB
testcase_21 AC 975 ms
7,824 KB
testcase_22 AC 971 ms
7,660 KB
testcase_23 AC 277 ms
6,248 KB
testcase_24 AC 1,302 ms
7,644 KB
testcase_25 AC 16 ms
4,564 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 975 ms
7,836 KB
testcase_28 AC 1,301 ms
7,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 second

const 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;
}
0