結果

問題 No.1665 quotient replace
ユーザー shun2741shun2741
提出日時 2021-09-03 22:30:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 361 ms / 3,000 ms
コード長 2,282 bytes
コンパイル時間 4,085 ms
コンパイル使用メモリ 263,132 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2023-08-21 23:14:52
合計ジャッジ時間 12,006 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
11,660 KB
testcase_01 AC 26 ms
11,656 KB
testcase_02 AC 26 ms
11,668 KB
testcase_03 AC 26 ms
11,796 KB
testcase_04 AC 26 ms
11,740 KB
testcase_05 AC 26 ms
11,596 KB
testcase_06 AC 28 ms
11,624 KB
testcase_07 AC 26 ms
11,676 KB
testcase_08 AC 27 ms
11,968 KB
testcase_09 AC 34 ms
11,768 KB
testcase_10 AC 134 ms
11,608 KB
testcase_11 AC 284 ms
11,672 KB
testcase_12 AC 49 ms
11,768 KB
testcase_13 AC 357 ms
11,680 KB
testcase_14 AC 359 ms
11,824 KB
testcase_15 AC 355 ms
11,796 KB
testcase_16 AC 361 ms
11,616 KB
testcase_17 AC 356 ms
11,672 KB
testcase_18 AC 26 ms
11,736 KB
testcase_19 AC 26 ms
11,604 KB
testcase_20 AC 26 ms
11,628 KB
testcase_21 AC 26 ms
11,816 KB
testcase_22 AC 27 ms
11,744 KB
testcase_23 AC 25 ms
11,628 KB
testcase_24 AC 27 ms
11,800 KB
testcase_25 AC 26 ms
11,600 KB
testcase_26 AC 27 ms
11,820 KB
testcase_27 AC 27 ms
11,800 KB
testcase_28 AC 34 ms
11,808 KB
testcase_29 AC 45 ms
11,600 KB
testcase_30 AC 180 ms
11,676 KB
testcase_31 AC 262 ms
11,816 KB
testcase_32 AC 261 ms
11,964 KB
testcase_33 AC 108 ms
11,940 KB
testcase_34 AC 217 ms
11,800 KB
testcase_35 AC 195 ms
11,608 KB
testcase_36 AC 209 ms
11,608 KB
testcase_37 AC 190 ms
11,616 KB
testcase_38 AC 223 ms
11,812 KB
testcase_39 AC 167 ms
11,844 KB
testcase_40 AC 166 ms
11,756 KB
testcase_41 AC 166 ms
11,768 KB
testcase_42 AC 25 ms
11,624 KB
testcase_43 AC 27 ms
11,972 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:115:5: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
  115 |     if(ans != 0){
      |     ^~
main.cpp:100:8: 備考: ‘ans’ はここで定義されています
  100 |     ll ans;
      |        ^~~

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

// デバッグ表示
#define dump(x) cout << #x << ":" << (x) << endl;

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// modint
using mint = modint1000000007;
// using mint = modint998244353;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第2引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// コンビネーションを計算する関数
ll pow(ll N, ll k) {
    ll res = 1;
    for (ll i = 0; i < k; ++i) res *= N;
    return res;
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

vector<bool> Ptable;
vector<int> PL;

// n以下の素数を作る
// Ptableにboolで素数かどうか
// PLに素数を入れていく
void make_prime_list(ll N){
    Ptable.resize(N+1, true);

    // 1は素数ではない
    Ptable[1] = false;
    for(ll i=2; i*i<=N; i++){
        for(ll j=2; i*j<=N; j++){
            Ptable[i*j] = false;
        }
    }

    for(ll i=2; i<=N; i++){
        if(Ptable[i]) PL.push_back(i);
    }
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    int K = 1000010;
    vector<ll> A(K+1);
    make_prime_list(K);

    for(auto v: PL){
        ll t1 = v;
        while(1){
            ll t2 = t1;
            while(t2 <= K){
                A[t2]++;
                t2 += t1;
            }
            if(t1 * v > K) break;
            t1 *= v;
        }
    }

    ll ans;
    REP(i, N){
        ll a;
        cin >> a;
        
        ll k = A[a];
        // dump(k);
        if(i == 0){
            ans = k;
        }
        else{
            ans = ans ^ k;
        }
    }

    if(ans != 0){
        cout << "white" << endl;
    }
    else{
        cout << "black" << endl;
    }

    return 0;
}
0