結果

問題 No.103 素因数ゲーム リターンズ
ユーザー なお
提出日時 2014-12-14 23:44:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 909 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 163,448 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 21:09:43
合計ジャッジ時間 2,187 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))

// 素因数分解
vector<pair<int,int> > pdecomp(unsigned int n){
    vector<pair<int,int> > res;
    unsigned int e = 0; while(n % 2 == 0){ n /= 2, e++; }
    if(e) res.push_back(make_pair(2,e));
    for(unsigned int p = 3; p*p <= n; p += 2){
        unsigned int e = 0; while(n % p == 0){ n /= p, e++; }
        if(e) res.push_back(make_pair(p,e));
    }
    if(n != 1) res.push_back(make_pair(n,1));
    return res;
}

int main(){
    int N, M;
    int K = 0;
    cin >> N;
    REP(i,N){
        cin >> M;
        vector<pair<int,int> > m = pdecomp(M);
        for(auto v : m){
            int k = v.second;
            K ^= k % 3;
        }
    }
    if(K){
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }
}
0