結果

問題 No.2211 Frequency Table of GCD
ユーザー keisuke6keisuke6
提出日時 2023-02-10 21:40:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 2,022 ms
コンパイル使用メモリ 201,480 KB
実行使用メモリ 6,492 KB
最終ジャッジ日時 2023-09-21 22:46:12
合計ジャッジ時間 28,634 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 805 ms
6,200 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 20 ms
4,380 KB
testcase_09 AC 15 ms
4,380 KB
testcase_10 AC 43 ms
4,376 KB
testcase_11 AC 29 ms
4,380 KB
testcase_12 AC 47 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 902 ms
6,212 KB
testcase_24 AC 1,985 ms
6,244 KB
testcase_25 AC 31 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 1,983 ms
6,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int int_pow(int x, int n, int MOD) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret = ret * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return ret;
}
signed main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M+1);
  for(int i=0;i<N;i++){
      int x;
      cin>>x;
      for(int j=1;j*j<=x;j++){
          if(x%j == 0){
              A[j]++;
              if(j*j != x) A[x/j]++;
          }
      }
  }
  vector<int> S(M+1);
  int mod = 998244353;
  for(int i=M;i>0;i--){
      S[i] += int_pow(2,A[i],mod)-1;
      S[i] += 100*mod;
      S[i] %= mod;
      for(int j=1;j*j<=i;j++){
          if(i%j == 0){
              if(j == i) continue;
              S[j] -= S[i];
              if(j*j != i && j != 1) S[i/j] -= S[i];
          }
      }
  }
  for(int i=1;i<=M;i++) cout<<S[i]<<endl;
}
0