結果

問題 No.103 素因数ゲーム リターンズ
ユーザー mayoko_mayoko_
提出日時 2015-05-09 22:52:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 1,324 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 157,600 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-19 09:35:19
合計ジャッジ時間 5,278 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
4,384 KB
testcase_01 AC 100 ms
4,384 KB
testcase_02 AC 101 ms
4,384 KB
testcase_03 AC 101 ms
4,384 KB
testcase_04 AC 101 ms
4,384 KB
testcase_05 AC 102 ms
4,380 KB
testcase_06 AC 101 ms
4,380 KB
testcase_07 AC 100 ms
4,380 KB
testcase_08 AC 101 ms
4,384 KB
testcase_09 AC 101 ms
4,380 KB
testcase_10 AC 100 ms
4,384 KB
testcase_11 AC 100 ms
4,380 KB
testcase_12 AC 101 ms
4,384 KB
testcase_13 AC 100 ms
4,380 KB
testcase_14 AC 100 ms
4,384 KB
testcase_15 AC 101 ms
4,384 KB
testcase_16 AC 101 ms
4,380 KB
testcase_17 AC 101 ms
4,380 KB
testcase_18 AC 100 ms
4,380 KB
testcase_19 AC 101 ms
4,380 KB
testcase_20 AC 100 ms
4,384 KB
testcase_21 AC 100 ms
4,380 KB
testcase_22 AC 101 ms
4,380 KB
testcase_23 AC 100 ms
4,380 KB
testcase_24 AC 101 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int MAXN = 10010;

map<ll, int> bunkai(ll N) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            while (N%i == 0) {
                ret[i]++;
                N /= i;
            }
        }
    }
    if (N>1) ret[N]++;
    return ret;
}

int g[MAXN];

int grundy(int n) {
    set<int> s;
    if (n == 0) return g[0] = 0;
    if (n == 1) return g[1] = 1;
    for (int i = 1; i <= 2; i++) {
        s.insert(grundy(n-i));
    }
    int cur = 0;
    for (int el : s) {
        if (cur >= el) cur = el+1;
    }
    return g[n] = cur;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    grundy(30);
    int N;
    cin >> N;
    vector<int> nums;
    for (int i = 0; i < N; i++) {
        int M;
        cin >> M;
        auto m = bunkai(M);
        for (auto p : m) {
            nums.push_back(p.second);
        }
    }
    int m = nums.size();
    int x = 0;
    for (int i = 0; i < m; i++) {
        x ^= g[nums[i]];
    }
    if (x == 0) cout << "Bob" << endl;
    else cout << "Alice" << endl;
    return 0;
}
0