結果

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

ソースコード

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