結果

問題 No.2 素因数ゲーム
ユーザー Hydrogen332
提出日時 2024-10-30 19:31:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 841 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 196,172 KB
最終ジャッジ日時 2025-02-25 01:53:01
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i)
#define all(a) (a).begin(), (a).end()

vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll ex = 0;
        
        while (n % i == 0) {
            ex++;
            n /= i;
        }
        
        res.push_back(make_pair(i, ex));
    }
    
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    cin.tie(nullptr);
    
    ll N;
    cin >> N;
    
    vector<pair<ll, ll>> primes = prime_factorize(N);
    int siz = primes.size();
    
    ll grundy = 0;
    rep(i, 0, siz) grundy ^= primes[i].second;
    
    if (grundy == 0) cout << "Bob\n";
    else cout << "Alice\n";
}
0