結果

問題 No.2211 Frequency Table of GCD
ユーザー Nzt3Nzt3
提出日時 2023-02-11 09:21:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 204,904 KB
実行使用メモリ 27,504 KB
最終ジャッジ日時 2023-09-22 08:16:26
合計ジャッジ時間 8,893 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 225 ms
24,036 KB
testcase_04 AC 169 ms
18,564 KB
testcase_05 AC 210 ms
21,492 KB
testcase_06 AC 219 ms
22,172 KB
testcase_07 AC 281 ms
25,144 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 15 ms
4,376 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 16 ms
4,376 KB
testcase_13 AC 130 ms
17,844 KB
testcase_14 AC 256 ms
24,864 KB
testcase_15 AC 179 ms
22,984 KB
testcase_16 AC 194 ms
23,884 KB
testcase_17 AC 170 ms
21,132 KB
testcase_18 AC 260 ms
27,388 KB
testcase_19 AC 275 ms
27,352 KB
testcase_20 AC 307 ms
27,468 KB
testcase_21 AC 320 ms
27,504 KB
testcase_22 AC 342 ms
27,416 KB
testcase_23 AC 214 ms
25,856 KB
testcase_24 AC 235 ms
27,476 KB
testcase_25 AC 14 ms
4,524 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 213 ms
27,464 KB
testcase_28 AC 209 ms
27,452 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);
  vector<vector<int>>D(M+1);
  for(int i=1;i<=M;i++){
    for(int j=i;j<=M;j+=i){
      D[j].push_back(i);
    }
  }
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    for(int j:D[A]){
      ++cnt[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