結果

問題 No.1665 quotient replace
ユーザー milanis48663220milanis48663220
提出日時 2021-09-03 21:27:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 206 ms / 3,000 ms
コード長 1,341 bytes
コンパイル時間 1,150 ms
コンパイル使用メモリ 116,352 KB
最終ジャッジ日時 2025-01-24 04:47:25
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

int cnt[1000001];
int v[1000001];
int g[1000001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int i = 1; i <= 1000000; i++) v[i] = i;
    for(int i = 2; i <= 1000000; i++){
        for(int j = 1; i*j <= 1000000; j++){
            while(v[i*j]%i == 0){
                g[i*j]++;
                v[i*j] /= i;
            }
        }
    }
    int x = 0;
    for(int i = 1; i <= 1000000; i++){
        if(cnt[i]%2 == 1) x ^= g[i];
    }
    if(x == 0) cout << "black" << endl;
    else cout << "white" << endl;
}
0