結果

問題 No.103 素因数ゲーム リターンズ
ユーザー nvt4snvt4s
提出日時 2019-04-30 02:25:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,703 ms / 5,000 ms
コード長 1,401 bytes
コンパイル時間 1,952 ms
コンパイル使用メモリ 150,416 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 21:28:43
合計ジャッジ時間 27,647 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
4,376 KB
testcase_01 AC 76 ms
4,376 KB
testcase_02 AC 38 ms
4,376 KB
testcase_03 AC 147 ms
4,380 KB
testcase_04 AC 75 ms
4,376 KB
testcase_05 AC 185 ms
4,376 KB
testcase_06 AC 38 ms
4,380 KB
testcase_07 AC 40 ms
4,376 KB
testcase_08 AC 39 ms
4,380 KB
testcase_09 AC 74 ms
4,380 KB
testcase_10 AC 143 ms
4,376 KB
testcase_11 AC 515 ms
4,376 KB
testcase_12 AC 1,735 ms
4,380 KB
testcase_13 AC 1,648 ms
4,376 KB
testcase_14 AC 2,018 ms
4,376 KB
testcase_15 AC 1,970 ms
4,380 KB
testcase_16 AC 453 ms
4,376 KB
testcase_17 AC 2,352 ms
4,384 KB
testcase_18 AC 987 ms
4,376 KB
testcase_19 AC 3,277 ms
4,376 KB
testcase_20 AC 947 ms
4,380 KB
testcase_21 AC 1,482 ms
4,380 KB
testcase_22 AC 1,097 ms
4,376 KB
testcase_23 AC 1,260 ms
4,380 KB
testcase_24 AC 3,703 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;
//素数判定O(√n)
bool Prime(ll n){
    if(n <= 1){
        return 0;
    }
    bool a = true;
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            a = false;
        }
    }
    return a;
}

//素因数分解O(√n)
vector<pair<ll, int>> MakePrimeList(ll x){
    vector<pair<ll, int>> PrimeList;
    for(int i = 2; i < 32000; i++){
        if(Prime(i) == 0) continue;
        int cnt = 0;
        while(x % i == 0){
            cnt++;
            x /= i;
        }
        if(cnt){
            PrimeList.push_back({i, cnt});
        }
    }
    if(Prime(x)){
        PrimeList.push_back({x, 1});
    }
    return PrimeList;
}

int main() {
    int N;
    cin >> N;
    int XOR = -1;
    for(int i = 0; i < N; i++){
        int M;
        cin >> M;
        vector<pair<ll, int>> P = MakePrimeList(M);
        vector<int> g(0);
        for(int i = 0; i < P.size(); i++){
            g.push_back(P.at(i).second % 3);
        }
        for(int i = 0; i < g.size(); i++){
            if(XOR == -1){
                XOR = g.at(0);
            }else{
                XOR = XOR xor g.at(i);
            }
        }
    }
    if(XOR){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
    
}
0