結果

問題 No.1946 ロッカーの問題
ユーザー osk_x64osk_x64
提出日時 2022-05-20 23:15:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 266 ms / 3,000 ms
コード長 801 bytes
コンパイル時間 5,065 ms
コンパイル使用メモリ 262,684 KB
実行使用メモリ 4,896 KB
最終ジャッジ日時 2023-10-20 14:08:15
合計ジャッジ時間 7,073 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,896 KB
testcase_03 AC 234 ms
4,896 KB
testcase_04 AC 3 ms
4,896 KB
testcase_05 AC 6 ms
4,368 KB
testcase_06 AC 7 ms
4,632 KB
testcase_07 AC 6 ms
4,368 KB
testcase_08 AC 56 ms
4,348 KB
testcase_09 AC 201 ms
4,632 KB
testcase_10 AC 163 ms
4,632 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 29 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 103 ms
4,348 KB
testcase_18 AC 266 ms
4,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
using ll = long long;

const int INF = 1 << 30;

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> locker(N), open(N);
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    A--;
    open[A]++;
  }
  
  int ans = 0;
  for (int i = N; i > 0; i--) {
    if(open[i-1] == locker[i-1]) {
      ans++;
      continue;
    }
    
    locker[i-1]++;
    locker[i-1] %= 2;
    for (int j = 1; j*j <= i; j++) {
      if(i%j) continue;
      locker[j-1]++;
      locker[j-1] %= 2;
      if(i/j != j) {
        locker[i/j -1]++;
        locker[i/j -1] %= 2;
      }
    }
  }

  cout << ans << endl;
  return 0;
}
0