結果

問題 No.1665 quotient replace
ユーザー Focus_SashFocus_Sash
提出日時 2021-09-03 21:55:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 234 ms / 3,000 ms
コード長 5,214 bytes
コンパイル時間 4,454 ms
コンパイル使用メモリ 261,496 KB
実行使用メモリ 15,188 KB
最終ジャッジ日時 2023-08-21 21:29:43
合計ジャッジ時間 9,494 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,052 KB
testcase_01 AC 8 ms
6,936 KB
testcase_02 AC 9 ms
7,032 KB
testcase_03 AC 8 ms
6,904 KB
testcase_04 AC 8 ms
6,936 KB
testcase_05 AC 9 ms
7,116 KB
testcase_06 AC 10 ms
7,052 KB
testcase_07 AC 9 ms
7,048 KB
testcase_08 AC 9 ms
7,096 KB
testcase_09 AC 15 ms
7,316 KB
testcase_10 AC 85 ms
9,692 KB
testcase_11 AC 177 ms
12,988 KB
testcase_12 AC 26 ms
7,692 KB
testcase_13 AC 232 ms
14,816 KB
testcase_14 AC 234 ms
15,188 KB
testcase_15 AC 223 ms
14,776 KB
testcase_16 AC 228 ms
14,664 KB
testcase_17 AC 230 ms
14,728 KB
testcase_18 AC 9 ms
7,052 KB
testcase_19 AC 8 ms
7,148 KB
testcase_20 AC 9 ms
6,988 KB
testcase_21 AC 9 ms
7,040 KB
testcase_22 AC 8 ms
6,976 KB
testcase_23 AC 9 ms
7,068 KB
testcase_24 AC 9 ms
7,100 KB
testcase_25 AC 9 ms
6,892 KB
testcase_26 AC 9 ms
6,948 KB
testcase_27 AC 9 ms
7,060 KB
testcase_28 AC 13 ms
7,208 KB
testcase_29 AC 17 ms
7,508 KB
testcase_30 AC 67 ms
10,884 KB
testcase_31 AC 97 ms
13,140 KB
testcase_32 AC 169 ms
12,620 KB
testcase_33 AC 69 ms
9,092 KB
testcase_34 AC 134 ms
11,616 KB
testcase_35 AC 125 ms
11,188 KB
testcase_36 AC 135 ms
11,448 KB
testcase_37 AC 120 ms
11,056 KB
testcase_38 AC 144 ms
11,932 KB
testcase_39 AC 103 ms
10,412 KB
testcase_40 AC 104 ms
10,360 KB
testcase_41 AC 100 ms
10,472 KB
testcase_42 AC 8 ms
6,888 KB
testcase_43 AC 8 ms
6,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using vl = vector<long long>;
using pl = pair<long long, long long>;
struct edge {long long to;long long cost;edge(long long t,long long c):to(t),cost(c){}};
using Graph = vector<vector<long long>>;
using WGraph = vector<vector<edge>>;
constexpr int dx[8]{1,0,-1,0,1,1,-1,-1};
constexpr int dy[8]{0,1,0,-1,1,-1,1,-1};
#define rep(i, n) for(long long (i) = 0; (i) < (n); (i)++)
#define reps(i, a, b) for(long long (i) = (a); (i) < (b); (i)++)
#define rrep(i, a, b) for(long long (i) = (a); (i) >= (b); (i)--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define V vector
constexpr long long MOD1 = 1000000007;
constexpr long long MOD9 =  998244353;
constexpr long long INF = MOD1*MOD1+1;
constexpr long long LL_MAX = std::numeric_limits<long long>::max();
long long safe_mod(long long n, long long m){if(n >= 0) {return n % m;} else return (n%m + m)%m;}
long long div_ceil(long long a, long long b){return (a + b - 1) / b;}
long long pw(long long x,long long n) {ll ret=1;while(n>0){if(n&1){ret=ret*x;}if(n>>=1){x=x*x;}}return ret;}
template<typename T> T SUM(const vector<T> &v){T ret{};return(accumulate(v.begin(), v.end(), ret));}
template<typename T> T MAX(const vector<T> &v){return *max_element(v.begin(), v.end());}
template<typename T> T MIN(const vector<T> &v){return *min_element(v.begin(), v.end());}
template<typename T> T pwmod(T x, long long n, long long m) {T ret=1;while(n>0){if(n&1)ret=ret*x%m;x=x*x%m;n>>=1;}return ret%m;}
template<typename T> void rsort(vector<T> &v) {sort(v.begin(), v.end(), greater<T>());}
template<typename T> bool chmax(T &a, const T& b) {if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a, const T& b) {if(a>b){a=b;return true;}return false;}
template<typename T, typename S> pair<T, S> mp(const T &a, const S &b){return make_pair(a, b);}
template<typename T> void uniquify(vector<T> &v){sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
template<typename T,typename S> ostream&operator<<(ostream&os,const pair<T,S>&p){os<<"("<<p.first<<", "<<p.second<<")";return os;}
template<typename T,typename S> ostream&operator<<(ostream&os,const map<T,S>&ma){for(auto [a,b]:ma){os<<"("<<a<<", "<<b<<")"<<" ";}return os;}
template<typename T> ostream &operator<<(ostream&os,const set<T>&s){os<<"{";for(auto c:s)os<<c<<" ";os<<"}";return os;}
template<typename T> ostream &operator<<(ostream&os,const vector<T>&v){os<<"[";for(int i=0;i<v.size();i++){os<<v[i]<<(i==v.size()-1?"]":" ");}return os;}
template<typename T> vector<int> compress(vector<T> &a){
    int n = a.size(); vector<int> ret(n); vector<T> temp = a;
    sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end());
    for(int i = 0; i < n; i++) ret[i] = lower_bound(a.begin(), a.end(), temp[i]) - a.begin();
    return ret;
}

#define ONLINE_JUDGE
#ifdef ONLINE_JUDGE
#define dump(x) true
#else
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#endif

template <typename T>
vector<long long> is_prime(T n){ //n以下の非負整数についてエラトステネスの篩を実行する
    assert(n >= 1);
    vector<long long> ret(n+1, 1);
    ret[0] = 0;
    ret[1] = 0;
    for(ll i = 2; i * i <= n; i++){
        if(!ret[i]) continue;
        for(long long j = i * i; j <= n; j += i) ret[j] = 0;
    }
    return ret;
}

template <typename T>
vector<T> prime_list(T n){ //n以下の素数のリストを返す
    vector<long long> v = is_prime(n);
    vector<long long> ret;
    for(int i = 0; i <= n; i++) if(v[i]) ret.emplace_back(i);
    return ret;
}

template <typename T>
vector<T> divisor(T n){ //nの約数を昇順に並べたvectorを返す
    vector<long long> ret;
    for(ll i = 1; i * i <= n; i++){
        if(n%i == 0){
            ret.pb(i);
            if(i * i != n) ret.emplace_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

template <typename T>
vector<pair<T, T>> prime_factor(T n) { //nの素因数と指数のペアのvectorを返す
    vector<pair<T, T>> ret;
    for (T i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        ret.emplace_back(i, tmp);
    }
    if (n != 1) ret.emplace_back(n, 1);
    return ret;
}

template <typename T>
vector<T> smallest_factor(T n){
    vector<T> ret(n+1);
    for(int i = 0; i <= n; i++) ret[i] = i;
    for(T i = 2; i * i <= n; i++){
        if(ret[i] == i){
            for(T j = i * i; j <= n; j += i){
                if(ret[j] == j) ret[j] = i;
            }
        }
    }
    return ret;
}

void solve(){
    ll n; cin >> n;
    vl a(n); rep(i, n) cin >> a[i];
    auto small = smallest_factor(1000010);
    dump(small);
    ll g = 0;
    rep(i, n){
        ll temp = 0;
        while(a[i] > 1){
            temp++;
            a[i] /= small[a[i]];
        }
        g ^= temp;
    }
    cout << (g == 0?"black":"white") << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);

    solve();

    return 0;
}
0