結果

問題 No.2211 Frequency Table of GCD
ユーザー Nzt3Nzt3
提出日時 2023-02-11 09:18:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 201,220 KB
実行使用メモリ 6,376 KB
最終ジャッジ日時 2023-09-22 08:13:47
合計ジャッジ時間 7,215 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 17 ms
4,500 KB
testcase_04 AC 100 ms
4,892 KB
testcase_05 AC 164 ms
5,448 KB
testcase_06 AC 90 ms
4,980 KB
testcase_07 AC 162 ms
5,416 KB
testcase_08 AC 10 ms
4,380 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 21 ms
4,380 KB
testcase_11 AC 15 ms
4,376 KB
testcase_12 AC 23 ms
4,380 KB
testcase_13 AC 84 ms
4,588 KB
testcase_14 AC 84 ms
4,792 KB
testcase_15 AC 56 ms
4,692 KB
testcase_16 AC 79 ms
4,764 KB
testcase_17 AC 148 ms
5,172 KB
testcase_18 AC 247 ms
6,164 KB
testcase_19 AC 245 ms
6,376 KB
testcase_20 AC 245 ms
6,092 KB
testcase_21 AC 246 ms
6,168 KB
testcase_22 AC 246 ms
6,116 KB
testcase_23 AC 15 ms
4,648 KB
testcase_24 AC 350 ms
6,120 KB
testcase_25 AC 15 ms
4,504 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 241 ms
6,172 KB
testcase_28 AC 351 ms
6,212 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);
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    for(int j=1;j*j<=A;j++){
      if(A%j==0){
        ++cnt[j];
        if(j*j!=A){
          ++cnt[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