結果

問題 No.1946 ロッカーの問題
ユーザー kabipoyokabipoyo
提出日時 2022-05-20 23:15:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 814 ms / 3,000 ms
コード長 1,465 bytes
コンパイル時間 4,417 ms
コンパイル使用メモリ 272,328 KB
実行使用メモリ 15,812 KB
最終ジャッジ日時 2023-10-20 14:08:28
合計ジャッジ時間 11,665 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 677 ms
4,988 KB
testcase_03 AC 814 ms
15,812 KB
testcase_04 AC 687 ms
4,988 KB
testcase_05 AC 440 ms
4,724 KB
testcase_06 AC 514 ms
4,724 KB
testcase_07 AC 362 ms
4,460 KB
testcase_08 AC 186 ms
7,628 KB
testcase_09 AC 709 ms
14,492 KB
testcase_10 AC 567 ms
12,908 KB
testcase_11 AC 11 ms
4,348 KB
testcase_12 AC 218 ms
5,252 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 27 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 294 ms
7,892 KB
testcase_18 AC 780 ms
12,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;
vector<lint> divisor(lint n) {
	vector<lint> v;
	for (lint i = 1; i*i <= n; i++) {
		if (n % i == 0) {
			v.push_back(i);
			if (i*i != n) v.push_back(n/i);
		}
	}
	sort(v.begin(), v.end());
	return v;
}

int main() {
	lint N, M;
	cin >> N >> M;
	vi v(M);
	vin(v);

	lint a=0, b=0, c=0, x, y, z;
	set<lint> s;
	rep(i, M) s.insert(v[i]);
	vi w(N+1);
	for (size_t i = N; i > 0; i--) {
		vi t = divisor(i);
		rep(j, t.size()) w[t[j]] ^= 1;
		if ((w[i] && !s.count(i)) || (!w[i] && s.count(i))) {
			b++;
			rep(j, t.size()) w[t[j]] ^= 1;
		}
	}
	std::cout << b << '\n';
}
0