結果

問題 No.2211 Frequency Table of GCD
ユーザー SSRSSSRS
提出日時 2023-02-10 21:31:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 326 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 1,395 ms
コンパイル使用メモリ 168,600 KB
実行使用メモリ 7,892 KB
最終ジャッジ日時 2023-09-22 00:59:42
合計ジャッジ時間 8,496 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 238 ms
5,144 KB
testcase_04 AC 203 ms
5,676 KB
testcase_05 AC 238 ms
6,388 KB
testcase_06 AC 237 ms
6,224 KB
testcase_07 AC 282 ms
6,788 KB
testcase_08 AC 14 ms
4,376 KB
testcase_09 AC 10 ms
4,376 KB
testcase_10 AC 28 ms
4,828 KB
testcase_11 AC 20 ms
4,376 KB
testcase_12 AC 30 ms
5,112 KB
testcase_13 AC 189 ms
5,472 KB
testcase_14 AC 262 ms
6,192 KB
testcase_15 AC 237 ms
5,352 KB
testcase_16 AC 252 ms
5,648 KB
testcase_17 AC 235 ms
6,196 KB
testcase_18 AC 326 ms
7,884 KB
testcase_19 AC 323 ms
7,756 KB
testcase_20 AC 323 ms
7,848 KB
testcase_21 AC 315 ms
7,892 KB
testcase_22 AC 317 ms
7,856 KB
testcase_23 AC 260 ms
5,336 KB
testcase_24 AC 324 ms
7,756 KB
testcase_25 AC 30 ms
5,328 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 313 ms
7,788 KB
testcase_28 AC 316 ms
7,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int> cnt(M + 1, 0);
  for (int i = 0; i < N; i++){
    cnt[A[i]]++;
  }
  vector<long long> POW(N + 1);
  POW[0] = 1;
  for (int i = 0; i < N; i++){
    POW[i + 1] = POW[i] * 2 % MOD;
  }
  vector<long long> B(M + 1, 0);
  for (int i = 1; i <= M; i++){
    for (int j = i; j <= M; j += i){
      B[i] += cnt[j];
    }
    B[i] = POW[B[i]] - 1;
  }
  for (int i = M; i >= 1; i--){
    for (int j = i * 2; j <= M; j += i){
      B[i] += MOD - B[j];
    }
    B[i] %= MOD;
  }
  for (int i = 1; i <= M; i++){
    cout << B[i] << endl;
  }
}
0