結果

問題 No.1946 ロッカーの問題
ユーザー osk_x64
提出日時 2022-05-20 23:15:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 279 ms / 3,000 ms
コード長 801 bytes
コンパイル時間 4,552 ms
コンパイル使用メモリ 250,148 KB
最終ジャッジ日時 2025-01-29 11:39:08
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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