結果

問題 No.1665 quotient replace
ユーザー KudeKude
提出日時 2021-09-03 21:36:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,299 ms / 3,000 ms
コード長 2,582 bytes
コンパイル時間 5,859 ms
コンパイル使用メモリ 264,176 KB
実行使用メモリ 125,984 KB
最終ジャッジ日時 2023-08-21 20:26:01
合計ジャッジ時間 103,290 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,099 ms
125,692 KB
testcase_01 AC 2,299 ms
125,760 KB
testcase_02 AC 2,091 ms
125,920 KB
testcase_03 AC 2,082 ms
125,696 KB
testcase_04 AC 2,106 ms
125,708 KB
testcase_05 AC 2,092 ms
125,776 KB
testcase_06 AC 2,115 ms
125,716 KB
testcase_07 AC 2,129 ms
125,836 KB
testcase_08 AC 2,129 ms
125,708 KB
testcase_09 AC 2,124 ms
125,784 KB
testcase_10 AC 2,159 ms
125,780 KB
testcase_11 AC 2,194 ms
125,772 KB
testcase_12 AC 2,116 ms
125,984 KB
testcase_13 AC 2,239 ms
125,692 KB
testcase_14 AC 2,236 ms
125,696 KB
testcase_15 AC 2,227 ms
125,764 KB
testcase_16 AC 2,259 ms
125,972 KB
testcase_17 AC 2,242 ms
125,724 KB
testcase_18 AC 2,129 ms
125,776 KB
testcase_19 AC 2,135 ms
125,960 KB
testcase_20 AC 2,111 ms
125,848 KB
testcase_21 AC 2,109 ms
125,696 KB
testcase_22 AC 2,100 ms
125,828 KB
testcase_23 AC 2,084 ms
125,692 KB
testcase_24 AC 2,083 ms
125,760 KB
testcase_25 AC 2,152 ms
125,720 KB
testcase_26 AC 2,100 ms
125,748 KB
testcase_27 AC 2,094 ms
125,768 KB
testcase_28 AC 2,095 ms
125,704 KB
testcase_29 AC 2,083 ms
125,708 KB
testcase_30 AC 2,142 ms
125,828 KB
testcase_31 AC 2,178 ms
125,828 KB
testcase_32 AC 2,201 ms
125,692 KB
testcase_33 AC 2,149 ms
125,772 KB
testcase_34 AC 2,169 ms
125,780 KB
testcase_35 AC 2,169 ms
125,692 KB
testcase_36 AC 2,180 ms
125,764 KB
testcase_37 AC 2,166 ms
125,708 KB
testcase_38 AC 2,196 ms
125,924 KB
testcase_39 AC 2,171 ms
125,788 KB
testcase_40 AC 2,164 ms
125,848 KB
testcase_41 AC 2,161 ms
125,776 KB
testcase_42 AC 2,131 ms
125,772 KB
testcase_43 AC 2,123 ms
125,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n)for (int i = 0; i < int(n); ++i)
#define rrep(i,n)for (int i = int(n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
std::pair<std::vector<int>,std::vector<int>> primes_lpf(const int n) {
    std::pair<std::vector<int>,std::vector<int>> rv;
    std::vector<int>& primes = rv.first;
    std::vector<int>& lpf = rv.second;
    primes.reserve(n / 10);
    lpf.resize(n + 1);
    for(int i = 2; i <= n; i += 2) lpf[i] = 2;
    for(int i = 3; i <= n; i += 6) lpf[i] = 3;
    if (2 <= n) primes.push_back(2);
    if (3 <= n) primes.push_back(3);
    // 5 * x <= n, x <= floor(n / 5)
    const int n5 = n / 5;
    int x = 5;
    bool one_mod6 = false;
    // x_1 <= n5, x_2 = x_1 + 2 <= n5 + 2 <= n
    for(; x <= n5; one_mod6 = !one_mod6, x += (one_mod6 ? 2 : 4)) {
        if (lpf[x] == 0) {
            lpf[x] = x;
            primes.push_back(x);
        }
        int px = lpf[x];
        for(int i = 2;; ++i) {
            int q = primes[i];
            int y = q * x;
            if (y > n) break;
            lpf[y] = q;
            if (q == px) break;
        }
    }
    for(; x <= n; one_mod6 = !one_mod6, x += (one_mod6 ? 2 : 4)) {
        if (lpf[x] == 0) {
            lpf[x] = x;
            primes.push_back(x);
        }
    }
    return rv;
}

auto [primes, lpf] = primes_lpf(1000000);

// global variable lpf must be defined
std::vector<std::pair<int,int>> factorize(int n) {
    std::vector<std::pair<int,int>> fs;
    while(n > 1) {
        int p = lpf[n];
        int cnt = 0;
        do {n /= p; cnt++;} while(n % p == 0);
        fs.emplace_back(p, cnt);
    }
    return fs;
}

int g[1000001];
VI dests[1000001];
bool table[1000001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(int i = 1; i <= 1000000; i++) {
        for(int x: dests[i]) table[x] = true;
        int t = 0;
        while(table[t]) t++;
        g[i] = t;
        for(int x: dests[i]) table[x] = false;
        for(int j = i + i; j <= 1000000; j += i) dests[j].push_back(t);
    }


    int n;
    cin >> n;
    int gr = 0;
    rep(_, n) {
        int x;
        cin >> x;
        gr ^= g[x];
    }
    cout << (gr ? "white" : "black") << endl;
}
0