結果

問題 No.1665 quotient replace
ユーザー eve__fuyuki
提出日時 2024-04-09 21:34:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2,082 ms / 3,000 ms
コード長 838 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 197,992 KB
最終ジャッジ日時 2025-02-20 23:32:27
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    const int M = 1e6;
    vector<vector<int>> fac(M + 1);
    for (int i = 1; i <= M; i++) {
        fac[i].push_back(i);
    }
    for (int i = 2; i <= M; i++) {
        for (int j = 2 * i; j <= M; j += i) {
            fac[j].push_back(i);
        }
    }
    vector<int> cnt(M + 1);
    cnt[1] = 0;
    for (int i = 2; i <= M; i++) {
        if (fac[i].size() == 1) {
            cnt[i] = 1;
        } else {
            cnt[i] = cnt[i / fac[i][1]] + 1;
        }
    }
    int n;
    cin >> n;
    int grundy = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        grundy ^= cnt[a[i]];
    }
    cout << (grundy ? "white" : "black") << endl;
}
0