結果

問題 No.2 素因数ゲーム
ユーザー ks115
提出日時 2020-07-16 23:10:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 761 bytes
コンパイル時間 1,965 ms
コンパイル使用メモリ 195,412 KB
最終ジャッジ日時 2025-01-11 21:39:43
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

template<class T>
vector<pair<T, T>> PrimeFactorization(T n) {
    vector<pair<T, T>> f;
    for (T i = 2; i * i <= n; i++) {
        T cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) f.push_back(make_pair(i, cnt));
    }
    if (n != 1) f.push_back(make_pair(n, 1));
    return f;
}

int main() {
    int N; cin >> N;

    auto factors = PrimeFactorization(N);

    int grundy = 0;
    for (auto f : factors) grundy ^= f.second;

    if (grundy) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}
0