結果

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){

    ll N, M, c, ans=0;
    cin >> N >> M;

    vector<ll> cnt(N+1), open(N+1);
    vector<vector<ll>> div(N+1);

    for (int i=1; i<=N; i++){
        for (int j=i; j<=N; j+=i) div[j].push_back(i);
    }

    for (int i=1; i<=M; i++){
        cin >> c;
        open[c] = 1;
    }

    for (int i=N; i>=1; i--){
        if (open[i] != (cnt[i]+1) % 2) ans++;
        else for (auto x : div[i]) cnt[x]++;
    }

    cout << ans << endl;

    return 0;
}
0