結果
問題 | No.1665 quotient replace |
ユーザー | kimiyuki |
提出日時 | 2021-09-03 22:55:45 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 302 ms / 3,000 ms |
コード長 | 3,470 bytes |
コンパイル時間 | 2,232 ms |
コンパイル使用メモリ | 207,636 KB |
実行使用メモリ | 15,780 KB |
最終ジャッジ日時 | 2024-05-09 06:12:06 |
合計ジャッジ時間 | 8,506 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
7,628 KB |
testcase_01 | AC | 13 ms
7,620 KB |
testcase_02 | AC | 12 ms
7,828 KB |
testcase_03 | AC | 12 ms
7,664 KB |
testcase_04 | AC | 11 ms
7,668 KB |
testcase_05 | AC | 11 ms
7,832 KB |
testcase_06 | AC | 13 ms
7,764 KB |
testcase_07 | AC | 12 ms
7,680 KB |
testcase_08 | AC | 13 ms
7,700 KB |
testcase_09 | AC | 20 ms
7,808 KB |
testcase_10 | AC | 110 ms
10,888 KB |
testcase_11 | AC | 225 ms
14,576 KB |
testcase_12 | AC | 34 ms
8,428 KB |
testcase_13 | AC | 302 ms
15,528 KB |
testcase_14 | AC | 292 ms
15,524 KB |
testcase_15 | AC | 292 ms
15,780 KB |
testcase_16 | AC | 292 ms
15,524 KB |
testcase_17 | AC | 296 ms
15,524 KB |
testcase_18 | AC | 12 ms
7,680 KB |
testcase_19 | AC | 12 ms
7,680 KB |
testcase_20 | AC | 11 ms
7,792 KB |
testcase_21 | AC | 12 ms
7,680 KB |
testcase_22 | AC | 11 ms
7,664 KB |
testcase_23 | AC | 12 ms
7,808 KB |
testcase_24 | AC | 11 ms
7,680 KB |
testcase_25 | AC | 11 ms
7,660 KB |
testcase_26 | AC | 12 ms
7,808 KB |
testcase_27 | AC | 12 ms
7,680 KB |
testcase_28 | AC | 17 ms
7,980 KB |
testcase_29 | AC | 22 ms
8,380 KB |
testcase_30 | AC | 87 ms
11,556 KB |
testcase_31 | AC | 128 ms
14,660 KB |
testcase_32 | AC | 232 ms
14,572 KB |
testcase_33 | AC | 90 ms
10,756 KB |
testcase_34 | AC | 175 ms
13,892 KB |
testcase_35 | AC | 181 ms
13,948 KB |
testcase_36 | AC | 171 ms
13,936 KB |
testcase_37 | AC | 156 ms
11,680 KB |
testcase_38 | AC | 183 ms
14,012 KB |
testcase_39 | AC | 131 ms
11,364 KB |
testcase_40 | AC | 131 ms
11,208 KB |
testcase_41 | AC | 131 ms
11,232 KB |
testcase_42 | AC | 12 ms
7,656 KB |
testcase_43 | AC | 11 ms
7,680 KB |
ソースコード
#line 1 "main.cpp" #include <bits/stdc++.h> #line 2 "/home/ubuntu/Library/utils/macros.hpp" #define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i)) #define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i)) #define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i)) #define ALL(x) std::begin(x), std::end(x) #line 7 "/home/ubuntu/Library/number/primes.hpp" struct prepared_primes { int size; std::vector<int> sieve; std::vector<int> primes; /** * @note O(size) */ prepared_primes(int size_) : size(size_) { sieve.resize(size); REP3 (p, 2, size) if (sieve[p] == 0) { primes.push_back(p); for (int k = p; k < size; k += p) { if (sieve[k] == 0) { sieve[k] = p; } } } } /** * @note let k be the length of the result, O(k) if n < size; O(\sqrt{n} + k) if size <= n < size^2 */ std::vector<int64_t> list_prime_factors(int64_t n) const { assert (1 <= n and n < (int64_t)size * size); std::vector<int64_t> result; // trial division for large part for (int p : primes) { if (n < size or n < (int64_t)p * p) { break; } while (n % p == 0) { n /= p; result.push_back(p); } } // small part if (n == 1) { // nop } else if (n < size) { while (n != 1) { result.push_back(sieve[n]); n /= sieve[n]; } } else { result.push_back(n); } assert (std::is_sorted(ALL(result))); return result; } std::vector<int64_t> list_all_factors(int64_t n) const { auto p = list_prime_factors(n); std::vector<int64_t> d; d.push_back(1); for (int l = 0; l < p.size(); ) { int r = l + 1; while (r < p.size() and p[r] == p[l]) ++ r; int n = d.size(); REP (k1, r - l) { REP (k2, n) { d.push_back(d[d.size() - n] * p[l]); } } l = r; } return d; } /** * @note O(1) if n < size; O(sqrt n) if size <= n < size^2 */ bool is_prime(int64_t n) const { assert (1 <= n and n < (int64_t)size * size); if (n < size) { return sieve[n] == n; } for (int p : primes) { if (n < (int64_t)p * p) { break; } if (n % p == 0) { return false; } } return true; } }; #line 4 "main.cpp" using namespace std; bool solve(int n, const std::vector<int> &a) { prepared_primes primes(1e6); vector<int> g; for (int a_i : a) { g.push_back(primes.list_prime_factors(a_i).size()); } int sum_g = 0; for (int g_i : g) { sum_g ^= g_i; } return sum_g; } // generated by oj-template v4.8.0 (https://github.com/online-judge-tools/template-generator) int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N; std::cin >> N; std::vector<int> A(N); REP (i, N) { std::cin >> A[i]; } auto ans = solve(N, A); std::cout << (ans ? "white" : "black") << '\n'; return 0; }