結果

問題 No.1946 ロッカーの問題
ユーザー 👑 platinumplatinum
提出日時 2022-04-13 09:00:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 263 ms / 3,000 ms
コード長 763 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 200,204 KB
実行使用メモリ 5,356 KB
最終ジャッジ日時 2023-08-24 18:50:33
合計ジャッジ時間 5,035 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,860 KB
testcase_03 AC 230 ms
5,356 KB
testcase_04 AC 4 ms
4,624 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 54 ms
4,380 KB
testcase_09 AC 198 ms
5,248 KB
testcase_10 AC 160 ms
4,880 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 101 ms
4,376 KB
testcase_18 AC 263 ms
5,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;
const int Max_N = (int)2e5;

int main(){
	int N, M;
	cin >> N >> M;
	assert(1 <= N && N <= Max_N);
	assert(0 <= M && M <= N);
	vector<int> A(M), B(N+1);
	rep(i,M) cin >> A[i];
	rep(i,M) assert(1 <= A[i] && A[i] <= N);
	rep(i,M-1) assert(A[i] < A[i+1]);
	rep(i,M) B[A[i]] = 1;
	vector<int> L(N+1);
	int ans = 0;
	for(int i = N; i > 0; i--){
		if(L[i] == B[i]) ans++;
		else{
			for(int j = 1; j * j <= i ; j++){
				if(i % j == 0){
					L[j] ^= 1;
					if(j * j != i) L[i/j] ^= 1;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}
0