結果

問題 No.1946 ロッカーの問題
ユーザー ruthenruthen
提出日時 2022-05-21 00:00:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 172 ms / 3,000 ms
コード長 787 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 205,420 KB
実行使用メモリ 25,296 KB
最終ジャッジ日時 2023-10-20 14:55:16
合計ジャッジ時間 4,084 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 134 ms
25,296 KB
testcase_03 AC 167 ms
25,296 KB
testcase_04 AC 149 ms
25,296 KB
testcase_05 AC 82 ms
19,412 KB
testcase_06 AC 95 ms
21,336 KB
testcase_07 AC 67 ms
17,112 KB
testcase_08 AC 34 ms
10,316 KB
testcase_09 AC 172 ms
22,984 KB
testcase_10 AC 110 ms
20,016 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 42 ms
12,504 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 9 ms
5,444 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 59 ms
14,180 KB
testcase_18 AC 154 ms
25,296 KB
権限があれば一括ダウンロードができます

ソースコード

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