結果

問題 No.1665 quotient replace
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-16 20:44:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 719 ms / 3,000 ms
コード長 949 bytes
コンパイル時間 1,131 ms
コンパイル使用メモリ 110,800 KB
最終ジャッジ日時 2025-02-10 03:53:56
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <sstream>

using namespace std;

vector<long long> spf;
map<long long, long long> prime;

void osa_k(long long n){
    spf.resize(n+1);
    for (long long i=0; i<=n; i++) spf[i] = i;
    for (long long i=2; i*i<=n; i++){
        if (spf[i] == i){
            for (long long j=2; i*j <= n; j++){
                spf[i*j] = min(spf[i*j], i);
            }
        }
    }
}

int prime_factor(long long n){
    prime.clear();
    int cnt = 0;
    while(n != 1){
        cnt++;
        prime[spf[n]]++;
        n /= spf[n];
    }
    return cnt;
}

int main(){
    osa_k(1000000);
    int N, A, g=0;
    cin >> N;

    for (int i=0; i<N; i++){
        cin >> A;
        g ^= prime_factor(A);
    }

    cout << (g == 0 ? "black" : "white") << endl;

    return 0;
}
0