結果

問題 No.1946 ロッカーの問題
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-29 14:27:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 358 ms / 3,000 ms
コード長 534 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 204,112 KB
実行使用メモリ 39,412 KB
最終ジャッジ日時 2023-09-20 09:55:21
合計ジャッジ時間 5,642 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 236 ms
39,288 KB
testcase_03 AC 358 ms
39,396 KB
testcase_04 AC 260 ms
39,412 KB
testcase_05 AC 166 ms
29,356 KB
testcase_06 AC 195 ms
32,588 KB
testcase_07 AC 141 ms
26,008 KB
testcase_08 AC 64 ms
14,672 KB
testcase_09 AC 279 ms
35,580 KB
testcase_10 AC 229 ms
30,432 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 75 ms
17,784 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 11 ms
6,256 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 100 ms
20,428 KB
testcase_18 AC 303 ms
39,344 KB
権限があれば一括ダウンロードができます

ソースコード

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