結果

問題 No.2 素因数ゲーム
ユーザー nvt4snvt4s
提出日時 2019-04-30 01:18:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 1,358 bytes
コンパイル時間 1,667 ms
コンパイル使用メモリ 150,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 05:05:35
合計ジャッジ時間 4,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
4,376 KB
testcase_01 AC 43 ms
4,376 KB
testcase_02 AC 43 ms
4,376 KB
testcase_03 AC 43 ms
4,380 KB
testcase_04 AC 42 ms
4,380 KB
testcase_05 AC 43 ms
4,376 KB
testcase_06 AC 43 ms
4,380 KB
testcase_07 AC 43 ms
4,380 KB
testcase_08 AC 43 ms
4,380 KB
testcase_09 AC 42 ms
4,376 KB
testcase_10 AC 43 ms
4,380 KB
testcase_11 AC 42 ms
4,380 KB
testcase_12 AC 43 ms
4,376 KB
testcase_13 AC 43 ms
4,380 KB
testcase_14 AC 42 ms
4,376 KB
testcase_15 AC 43 ms
4,380 KB
testcase_16 AC 43 ms
4,376 KB
testcase_17 AC 43 ms
4,380 KB
testcase_18 AC 42 ms
4,376 KB
testcase_19 AC 43 ms
4,376 KB
testcase_20 AC 42 ms
4,376 KB
testcase_21 AC 43 ms
4,380 KB
testcase_22 AC 43 ms
4,376 KB
testcase_23 AC 42 ms
4,380 KB
testcase_24 AC 43 ms
4,380 KB
testcase_25 AC 42 ms
4,376 KB
testcase_26 AC 43 ms
4,376 KB
testcase_27 AC 42 ms
4,376 KB
testcase_28 AC 43 ms
4,380 KB
testcase_29 AC 43 ms
4,376 KB
testcase_30 AC 43 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() {
    ll N;
    cin >> N;
    vector<pair<ll, int>> P = MakePrimeList(N);
    vector<int> Nim(0);
    for(int i = 0; i < P.size(); i++){
        Nim.push_back(P.at(i).second);
    }
    if(Nim.size() == 0){
        cout << "Alice" << endl;
    }else{
        ll XOR = Nim.at(0);
        for(int i = 1; i < Nim.size(); i++){
            XOR = XOR xor Nim.at(i);
        }
        if(XOR == 0){
            cout << "Bob" << endl;
        }else{
            cout << "Alice" << endl;
        }
    }
    
    
    
    
    
    
    
}
0