結果

問題 No.2211 Frequency Table of GCD
ユーザー Nzt3Nzt3
提出日時 2023-02-11 09:24:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 203,064 KB
実行使用メモリ 7,228 KB
最終ジャッジ日時 2023-09-22 08:18:12
合計ジャッジ時間 4,536 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 16 ms
5,156 KB
testcase_04 AC 22 ms
5,336 KB
testcase_05 AC 29 ms
5,940 KB
testcase_06 AC 23 ms
5,340 KB
testcase_07 AC 30 ms
6,172 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 12 ms
4,384 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 13 ms
4,388 KB
testcase_13 AC 19 ms
5,076 KB
testcase_14 AC 23 ms
5,616 KB
testcase_15 AC 19 ms
5,388 KB
testcase_16 AC 22 ms
5,652 KB
testcase_17 AC 27 ms
5,880 KB
testcase_18 AC 38 ms
6,940 KB
testcase_19 AC 39 ms
6,924 KB
testcase_20 AC 39 ms
6,960 KB
testcase_21 AC 39 ms
7,192 KB
testcase_22 AC 39 ms
7,028 KB
testcase_23 AC 18 ms
5,340 KB
testcase_24 AC 37 ms
6,936 KB
testcase_25 AC 14 ms
4,568 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 36 ms
7,228 KB
testcase_28 AC 37 ms
6,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin>>N>>M;
  vector<int>cnt(M+1),A(M+1);
  for(int i=0;i<N;i++){
    int T;
    cin>>T;
    ++A[T];
  }
  for(int i=1;i<=M;i++){
    for(int j=i;j<=M;j+=i){
      cnt[i]+=A[j];
    }
  }
  vector<long long>beki(N+1);
  beki[0]=1;
  vector<int>ans(M+1);
  for(int i=0;i<N;i++){
    beki[i+1]=beki[i]*2%mod;
  }
  for(int i=M;i>=1;i--){
    ans[i]=beki[cnt[i]]-1;
    for(int j=i*2;j<=M;j+=i){
      ans[i]-=ans[j];
      if(ans[i]<0)ans[i]+=mod;
    }
  }
  for(int i=1;i<=M;i++){
    cout<<ans[i]<<'\n';
  }
}
0