結果

問題 No.2211 Frequency Table of GCD
ユーザー keisuke6keisuke6
提出日時 2023-02-10 21:48:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,188 bytes
コンパイル時間 3,125 ms
コンパイル使用メモリ 218,336 KB
実行使用メモリ 7,868 KB
最終ジャッジ日時 2023-09-22 01:04:36
合計ジャッジ時間 29,170 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 826 ms
5,952 KB
testcase_04 AC 825 ms
5,684 KB
testcase_05 AC 1,135 ms
6,516 KB
testcase_06 AC 966 ms
6,220 KB
testcase_07 AC 1,329 ms
6,972 KB
testcase_08 AC 21 ms
4,380 KB
testcase_09 AC 16 ms
4,380 KB
testcase_10 AC 44 ms
4,380 KB
testcase_11 AC 30 ms
4,376 KB
testcase_12 AC 49 ms
4,380 KB
testcase_13 AC 739 ms
5,884 KB
testcase_14 AC 1,059 ms
6,472 KB
testcase_15 AC 895 ms
5,960 KB
testcase_16 AC 997 ms
6,312 KB
testcase_17 AC 1,076 ms
6,492 KB
testcase_18 AC 1,715 ms
7,840 KB
testcase_19 AC 1,706 ms
7,868 KB
testcase_20 AC 1,691 ms
7,800 KB
testcase_21 AC 1,701 ms
7,764 KB
testcase_22 AC 1,696 ms
7,840 KB
testcase_23 AC 256 ms
4,572 KB
testcase_24 AC 1,394 ms
6,124 KB
testcase_25 AC 33 ms
4,588 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1,681 ms
7,756 KB
testcase_28 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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),B(N);
  for(int i=0;i<N;i++){
      int x;
      cin>>x;
      B[i]=x;
      for(int j=1;j*j<=x;j++){
          if(x%j == 0){
              A[j]++;
              if(j*j != x) A[x/j]++;
          }
      }
  }
  bool ok = true;
  for(int i=1;i<N;i++)if(B[i] != B[i-1]) ok = false;
  int mod = 998244353;
  if(ok){
      for(int i=1;i<=M;i++){
          cout<<((B[0]==i)*(int_pow(2,N,mod)-1)+mod)%mod<<endl;
      }return 0;
  }
  vector<int> S(M+1);
  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]+1000000*mod)%mod<<endl;
}
0