結果

問題 No.1665 quotient replace
ユーザー nok0nok0
提出日時 2021-08-09 23:05:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 527 ms / 3,000 ms
コード長 1,191 bytes
コンパイル時間 2,997 ms
コンパイル使用メモリ 204,072 KB
実行使用メモリ 7,584 KB
最終ジャッジ日時 2023-08-21 18:53:47
合計ジャッジ時間 11,749 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
7,264 KB
testcase_01 AC 9 ms
7,456 KB
testcase_02 AC 9 ms
7,560 KB
testcase_03 AC 10 ms
7,532 KB
testcase_04 AC 10 ms
7,584 KB
testcase_05 AC 10 ms
7,264 KB
testcase_06 AC 13 ms
7,556 KB
testcase_07 AC 10 ms
7,528 KB
testcase_08 AC 11 ms
7,308 KB
testcase_09 AC 23 ms
7,324 KB
testcase_10 AC 173 ms
7,460 KB
testcase_11 AC 399 ms
7,532 KB
testcase_12 AC 50 ms
7,456 KB
testcase_13 AC 527 ms
7,308 KB
testcase_14 AC 521 ms
7,268 KB
testcase_15 AC 524 ms
7,456 KB
testcase_16 AC 511 ms
7,532 KB
testcase_17 AC 518 ms
7,476 KB
testcase_18 AC 10 ms
7,468 KB
testcase_19 AC 9 ms
7,332 KB
testcase_20 AC 9 ms
7,384 KB
testcase_21 AC 10 ms
7,456 KB
testcase_22 AC 9 ms
7,392 KB
testcase_23 AC 10 ms
7,392 KB
testcase_24 AC 10 ms
7,464 KB
testcase_25 AC 9 ms
7,576 KB
testcase_26 AC 11 ms
7,456 KB
testcase_27 AC 12 ms
7,528 KB
testcase_28 AC 21 ms
7,460 KB
testcase_29 AC 32 ms
7,536 KB
testcase_30 AC 189 ms
7,460 KB
testcase_31 AC 287 ms
7,532 KB
testcase_32 AC 367 ms
7,392 KB
testcase_33 AC 148 ms
7,384 KB
testcase_34 AC 303 ms
7,308 KB
testcase_35 AC 285 ms
7,384 KB
testcase_36 AC 293 ms
7,380 KB
testcase_37 AC 263 ms
7,528 KB
testcase_38 AC 327 ms
7,536 KB
testcase_39 AC 229 ms
7,268 KB
testcase_40 AC 238 ms
7,388 KB
testcase_41 AC 232 ms
7,384 KB
testcase_42 AC 9 ms
7,460 KB
testcase_43 AC 9 ms
7,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct osa_k {
private:
	std::vector<int> spf, pr;

public:
	osa_k() = default;

	osa_k(int MAX) : spf(MAX + 1) {
		for(int i = 2; i <= MAX; i++) {
			if(spf[i] == 0) {
				spf[i] = i;
				pr.push_back(i);
			}
			for(int j = 0; j < pr.size() and pr[j] <= spf[i] and i * pr[j] <= MAX; j++)
				spf[i * pr[j]] = pr[j];
		}
	}

	std::vector<std::pair<int, int>> PF(int n) {
		std::vector<std::pair<int, int>> divisor;
		if(n == 1) return divisor;
		int before = spf[n], cnt = 0;
		while(n > 1) {
			if(spf[n] == before) {
				cnt++;
				n /= spf[n];
			} else {
				divisor.emplace_back(before, cnt);
				before = spf[n];
				cnt = 1;
				n /= spf[n];
			}
		}
		divisor.emplace_back(before, cnt);
		return divisor;
	}

	int smallestprimefactor(const int n) const {
		return spf[n];
	}

	bool isPrime(const int n) const {
		return n == spf[n];
	}
};

const int m = 1000000;
osa_k pf(m);
int main() {
	int n;
	cin >> n;
	int fold = 0;
	while(n--) {
		int a;
		cin >> a;
		if(a == 1) continue;
		auto vec = pf.PF(a);
		int tmp = 0;
		for(auto [val, cnt] : vec) tmp += cnt;
		fold ^= tmp;
	}
	cout << (fold ? "white" : "black") << '\n';
	return 0;
}
0