結果

問題 No.2211 Frequency Table of GCD
ユーザー pointNpointN
提出日時 2023-03-17 17:49:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,099 ms / 2,000 ms
コード長 1,469 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 131,768 KB
実行使用メモリ 8,092 KB
最終ジャッジ日時 2023-10-18 13:45:47
合計ジャッジ時間 14,216 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,924 KB
testcase_01 AC 3 ms
4,924 KB
testcase_02 AC 3 ms
4,924 KB
testcase_03 AC 29 ms
6,508 KB
testcase_04 AC 299 ms
6,772 KB
testcase_05 AC 500 ms
7,300 KB
testcase_06 AC 263 ms
6,772 KB
testcase_07 AC 488 ms
7,300 KB
testcase_08 AC 22 ms
5,452 KB
testcase_09 AC 18 ms
5,188 KB
testcase_10 AC 47 ms
6,244 KB
testcase_11 AC 33 ms
5,716 KB
testcase_12 AC 52 ms
6,244 KB
testcase_13 AC 245 ms
6,508 KB
testcase_14 AC 242 ms
6,772 KB
testcase_15 AC 152 ms
6,508 KB
testcase_16 AC 225 ms
6,772 KB
testcase_17 AC 442 ms
7,036 KB
testcase_18 AC 760 ms
8,092 KB
testcase_19 AC 764 ms
8,092 KB
testcase_20 AC 765 ms
8,092 KB
testcase_21 AC 761 ms
8,092 KB
testcase_22 AC 759 ms
8,092 KB
testcase_23 AC 20 ms
6,448 KB
testcase_24 AC 1,096 ms
8,092 KB
testcase_25 AC 35 ms
6,508 KB
testcase_26 AC 3 ms
4,864 KB
testcase_27 AC 747 ms
8,092 KB
testcase_28 AC 1,099 ms
8,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

const ll mod = 998244353;

ll mpow(ll a, ll x){
  ll res = 1;
  while(x > 0){
    if(x & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    x >>= 1;
  }
  return res;
}

int main(){
  ll N,M; cin >> N >> M;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  vector<ll> ans(M+1,0);
  vector<ll> cnt(202000,0);
  rep(i,N){
    for(ll a=1;a*a<=A[i];a++){
      if(A[i]%a==0){
        cnt[a]++;
        if(a*a!=A[i]) cnt[A[i]/a]++;
      }
    }
  }
  for(int m=M;m>0;m--){
    ll a = (mpow(2,cnt[m])+mod-1);
    for(int mm=m*2;mm<=M;mm+=m){
      a += mod-ans[mm];
    }
    ans[m] = a%mod;
  }
  for(int i=1;i<=M;i++){
    cout << ans[i] << '\n';
  }
  return 0;
}
0