結果

問題 No.1946 ロッカーの問題
ユーザー SSRSSSRS
提出日時 2022-05-20 21:31:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 270 ms / 3,000 ms
コード長 560 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 174,360 KB
実行使用メモリ 25,472 KB
最終ジャッジ日時 2023-10-20 11:49:23
合計ジャッジ時間 4,343 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 189 ms
24,680 KB
testcase_03 AC 270 ms
25,472 KB
testcase_04 AC 186 ms
24,680 KB
testcase_05 AC 123 ms
18,940 KB
testcase_06 AC 154 ms
20,720 KB
testcase_07 AC 93 ms
16,828 KB
testcase_08 AC 51 ms
10,492 KB
testcase_09 AC 226 ms
23,096 KB
testcase_10 AC 172 ms
20,192 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 56 ms
12,340 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 9 ms
5,212 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 81 ms
13,924 KB
testcase_18 AC 265 ms
25,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++){
    cin >> A[i];
  }
  vector<bool> c(N + 1, true);
  for (int i = 0; i < M; i++){
    c[A[i]] = false;
  }
  vector<vector<int>> f(N + 1);
  for (int i = 1; i <= N; i++){
    for (int j = i; j <= N; j += i){
      f[j].push_back(i);
    }
  }
  int ans  = 0;
  for (int i = N; i > 0; i--){
    if (c[i]){
      ans++;
    } else {
      for (int j : f[i]){
        c[j] = !c[j];
      }
    }
  }
  cout << ans << endl;
}
0