結果

問題 No.1946 ロッカーの問題
ユーザー atjh16atjh16
提出日時 2022-09-23 12:48:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 279 ms / 3,000 ms
コード長 481 bytes
コンパイル時間 1,898 ms
コンパイル使用メモリ 198,032 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 20:48:36
合計ジャッジ時間 5,674 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 273 ms
4,376 KB
testcase_03 AC 116 ms
4,376 KB
testcase_04 AC 279 ms
4,380 KB
testcase_05 AC 171 ms
4,380 KB
testcase_06 AC 206 ms
4,376 KB
testcase_07 AC 145 ms
4,380 KB
testcase_08 AC 32 ms
4,380 KB
testcase_09 AC 105 ms
4,376 KB
testcase_10 AC 87 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 63 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 12 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 20 ms
4,380 KB
testcase_18 AC 39 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int n, m, a, t;
bool f[200001];

int main() {
	cin >> n >> m;

	for (int i = 0; i < m; i++) {		
		cin >> a;
		f[a] = 1;
	}

	for (int i = n; i > 0; i--) {
		int u = n / i;

		if ((u & 1) ^ f[i]) {
			t++;

			for (int j = 1; j < sqrt(i); j++) {
				if (i % j == 0) {
					f[j] = 1 - f[j];
					f[i / j] = 1 - f[i / j];
				}
			}

			int k = (int)sqrt(i);

			if (k * k == i) {
				f[k] = 1 - f[k];
			}
		}
	}

	cout << t << endl;
}
0