結果

問題 No.1665 quotient replace
ユーザー Sooh317Sooh317
提出日時 2021-09-03 21:49:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 283 ms / 3,000 ms
コード長 4,700 bytes
コンパイル時間 4,597 ms
コンパイル使用メモリ 265,960 KB
実行使用メモリ 11,168 KB
最終ジャッジ日時 2023-08-21 21:09:36
合計ジャッジ時間 10,853 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,272 KB
testcase_01 AC 14 ms
6,984 KB
testcase_02 AC 14 ms
7,128 KB
testcase_03 AC 14 ms
6,872 KB
testcase_04 AC 15 ms
7,020 KB
testcase_05 AC 14 ms
7,216 KB
testcase_06 AC 17 ms
7,196 KB
testcase_07 AC 14 ms
7,288 KB
testcase_08 AC 16 ms
7,348 KB
testcase_09 AC 22 ms
7,292 KB
testcase_10 AC 105 ms
8,560 KB
testcase_11 AC 218 ms
10,280 KB
testcase_12 AC 37 ms
7,640 KB
testcase_13 AC 280 ms
10,940 KB
testcase_14 AC 283 ms
11,056 KB
testcase_15 AC 270 ms
10,892 KB
testcase_16 AC 281 ms
11,168 KB
testcase_17 AC 281 ms
11,088 KB
testcase_18 AC 14 ms
7,208 KB
testcase_19 AC 14 ms
7,284 KB
testcase_20 AC 14 ms
7,084 KB
testcase_21 AC 14 ms
7,200 KB
testcase_22 AC 14 ms
6,868 KB
testcase_23 AC 14 ms
7,128 KB
testcase_24 AC 15 ms
7,140 KB
testcase_25 AC 14 ms
7,160 KB
testcase_26 AC 14 ms
7,180 KB
testcase_27 AC 15 ms
7,184 KB
testcase_28 AC 19 ms
7,472 KB
testcase_29 AC 23 ms
7,540 KB
testcase_30 AC 90 ms
9,068 KB
testcase_31 AC 129 ms
10,048 KB
testcase_32 AC 213 ms
9,860 KB
testcase_33 AC 88 ms
8,236 KB
testcase_34 AC 170 ms
9,364 KB
testcase_35 AC 161 ms
9,028 KB
testcase_36 AC 167 ms
9,284 KB
testcase_37 AC 155 ms
9,028 KB
testcase_38 AC 187 ms
9,556 KB
testcase_39 AC 136 ms
8,776 KB
testcase_40 AC 134 ms
8,788 KB
testcase_41 AC 131 ms
8,876 KB
testcase_42 AC 15 ms
7,100 KB
testcase_43 AC 15 ms
7,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *    author:  Sooh
 *    created: 03.09.2021 21:44:22
**/
#include<bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
//using mint = modint998244353;
//using mint = modint1000000007;
#endif
#pragma region template
using ll = long long;
template <class T> using V = vector<T>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cerr << endl;int cnt = 0;for(const auto& v : vv){cerr << cnt << "th : "; view(v); cnt++;} cerr << endl;}
ll power(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a;} a = a * a; p >>= 1;} return ret;}
ll modpow(ll a, ll p, ll mod){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0; while (b) {ll t = a / b ;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template<class T, class K>bool chmax(T &a, const K b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class K>bool chmin(T &a, const K b) { if (b<a) { a=b; return 1; } return 0; }
#pragma endregion
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
const int inf = 1001001001;
const ll INF = 1001001001001001001ll;
//const double pi = acos(-1);
//const ll mod = 998244353;
const ll mod = 1000000007;

struct Sieve {
    int MX;
    vector<bool> ip; // is prime
    vector<int> mu; // mobius
    vector<int> mf; // min factor
    Sieve(int _MX = 1000005, bool mobius = false):MX(_MX){
        ip.resize(MX, true);
        mf.resize(MX, 1);
        ip[0] = ip[1] = false;
        if(mobius){
            mu.resize(MX, 1);
            for(int i = 2; i < MX; i++){
                if(!ip[i]) continue;
                ip[i] = true;
                mf[i] = i;
                mu[i] = -1;
                for(int j = i+i; j < MX; j += i){
                    ip[j] = false;
                    if(mf[j] == 1) mf[j] = i;
                    if(j / i % i == 0) mu[j] = 0;
                    else mu[j] = -mu[j];
                }
            }
        }
        else{
            for(int i = 2; i < MX; i++){
                if(!ip[i]) continue;
                ip[i] = true;
                mf[i] = i;
                for(int j = i+i; j < MX; j += i){
                    ip[j] = false;
                    if(mf[j] == 1) mf[j] = i;
                }
            }
        }
    }

    vector<pair<int, int>> factorize(int n){
        vector<pair<int, int>> res;
        int p = mf[n], e = 0;
        while(n != 1){
            while(n % p == 0){
                n /= p;
                ++e;
            }
            res.emplace_back(p, e);
            p = mf[n], e = 0;
        }
        return res;
    }

    /* make 1-indexed vectors */
    // return F where F(i) = Σf(k) (i|k)
    template<class T> void fast_zeta(vector<T> &f){
        int N = f.size();
        for(int i = 2; i < N; i++){
            if(!ip[i]) continue;
            for(int j = (N - 1)/i; j >= 1; --j) f[j] += f[i*j];
        }
    }

    // return f where F(i) = Σf(k) (i|k)
    template<class T> void fast_mobius(vector<T> &F){
        int N = F.size();
        for(int i = 2; i < N; i++){
            if(!ip[i]) continue;
            for(int j = 1; j <= (N - 1)/i; ++j) F[j] -= F[i*j];
        }
    }

    // return h where h(k) = Σ f(i)*g(i) (gcd(i, j) = k) in O(NloglogN)
    template<class T> vector<T> gcd_convolution(const vector<T> &f, const vector<T> &g){
        int N = max(f.size(), g.size());
        vector<T> F(N), G(N), h(N);
        for(int i = 0; i < (int)f.size(); i++) F[i] = f[i];
        for(int i = 0; i < (int)g.size(); i++) G[i] = g[i];
        fast_zeta(F);
        fast_zeta(G);
        for(int i = 1; i < N; i++) h[i] = F[i] * G[i];
        fast_mobius(h);
        return h;
    }
};


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    Sieve s;
    int n; cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    int x = 0;
    rep(i,n){
        auto res = s.factorize(a[i]);
        int cnt = 0;
        for(auto p : res){
            cnt += p.se;
        }
        x ^= cnt;
    }
    cout << (x == 0 ? "black" : "white") << endl;
}
0