結果

問題 No.1946 ロッカーの問題
ユーザー ruthen71
提出日時 2022-05-21 00:00:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 316 ms / 3,000 ms
コード長 787 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 196,540 KB
最終ジャッジ日時 2025-01-29 12:09:24
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include "debug.hpp"
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    V<int> A(N + 1, 0);
    rep(i, M) {
        int a;
        cin >> a;
        A[a] = 1;
    }
    V<V<int>> G(N + 1);
    for (int i = 1; i <= N; i++) {
        for (int j = 2 * i; j <= N; j += i) {
            G[j].push_back(i);
        }
    }
    int ans = 0;
    for (int i = N; i > 0; i--) {
        if (A[i] == 0) {
            ans++;
        } else {
            for (auto j : G[i]) A[j] ^= 1;
        }
    }
    cout << ans << '\n';
    return 0;
}
0