結果

問題 No.1946 ロッカーの問題
ユーザー ぷらぷら
提出日時 2022-05-20 21:27:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 288 ms / 3,000 ms
コード長 593 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 202,908 KB
実行使用メモリ 4,896 KB
最終ジャッジ日時 2023-10-20 11:43:47
合計ジャッジ時間 4,125 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int>A(M),B(N+1);
    for(int i = 0; i < M; i++) {
        cin >> A[i];
        B[A[i]] = 1;
    }
    int ans = 0;
    for(int i = N; i >= 1; i--) {
        if(!B[i]) {
            ans++;
        }
        else {
            for(int j = 1; j*j <= i; j++) {
                if((i%j) == 0) {
                    B[j] ^= 1;
                    if(j*j != i) {
                        B[i/j] ^= 1;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
0