結果

問題 No.1946 ロッカーの問題
ユーザー MazesobaMazesoba
提出日時 2022-05-20 22:41:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 468 ms / 3,000 ms
コード長 1,463 bytes
コンパイル時間 4,271 ms
コンパイル使用メモリ 262,692 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 13:29:30
合計ジャッジ時間 8,128 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 459 ms
4,348 KB
testcase_03 AC 337 ms
4,348 KB
testcase_04 AC 468 ms
4,348 KB
testcase_05 AC 297 ms
4,348 KB
testcase_06 AC 342 ms
4,348 KB
testcase_07 AC 238 ms
4,348 KB
testcase_08 AC 79 ms
4,348 KB
testcase_09 AC 281 ms
4,348 KB
testcase_10 AC 226 ms
4,348 KB
testcase_11 AC 6 ms
4,348 KB
testcase_12 AC 117 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 19 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 102 ms
4,348 KB
testcase_18 AC 257 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;

//#define DISABLE_PRINT

#if defined(ENABLE_PRINT) && !defined(DISABLE_PRINT)

#define P(...) fprintf(stderr, __VA_ARGS__)
#define P2(fmt) fprintf(stderr, fmt)
#define LP fprintf(stderr, "L: %d\n", __LINE__)

#else

#define P(...) ((void)0)
#define P2(fmt) ((void)0)
#define LP ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using ull = unsigned long long;

int main(int, const char**)
{
    int N, M; cin >> N >> M;
    vector<bool> v(N);
    rep(i, N) {
        auto ti = i + 1;
        for(int j = 1; j * j <= ti; ++j) {
            if(ti % j != 0) continue;
            auto d = ti / j;
            v[j - 1] = !v[j - 1];
            if(j != d) {
                v[d - 1] = !v[d - 1];
            }
        }
    }

    vector<bool> act(N);
    rep(i, M) {
        int x; cin >> x;
        x--;
        act[x] = true;
    }

    int ans = 0;
    rep(i, N) {
        auto ti = N - i;
        if(v[ti - 1] == act[ti - 1]) continue;
        ans++;
        for(int j = 1; j * j <= ti; ++j) {
            if(ti % j != 0) continue;
            auto d = ti / j;
            v[d - 1] = !v[d - 1];
            if(d != j) {
                v[j - 1] = !v[j - 1];
            }
        }
    }

#if 0
    rep(i, N) {
        P("%d ", v[i] ? 1 : 0);
    }
    P("\n");
#endif    

    cout << ans << endl;
    return 0;
}
0