結果

問題 No.103 素因数ゲーム リターンズ
ユーザー hikikomorihikikomori
提出日時 2022-11-14 16:16:38
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,116 bytes
コンパイル時間 5,355 ms
コンパイル使用メモリ 315,360 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 22:52:32
合計ジャッジ時間 6,468 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<ll>>;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<long long, long long>;
using vpll = vector<pll>;
using mint = modint1000000007;
const long double EPS = 1e-18;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); i++)
#define rep(i, n) for (ll i = (0); i < (ll)(n); i++)
#define rrep(i, n) for (ll i = (1); i < (ll)(n + 1); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define rrepd(i, n) for (ll i = n; i >= 1; i--)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) (a <= x && x < b)
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
template <class T>
inline T CHMAX(T& a, const T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline T CHMIN(T& a, const T b) {
    return a = (a > b) ? b : a;
}
map<ll, ll> soinsu(ll N) {
    ll res = N;
    map<ll, ll> ma;

    for (ll i = 2; i * i <= N; i++) {
        while (res % i == 0) {
            res /= i;
            ma[i]++;
        }
    }

    if (res != 1) {
        ma[res]++;
    }

    return ma;
}
int main() {
    ll N;
    cin >> N;

    vll M(N);
    rep(i, N) { cin >> M[i]; }

    vll grundy(110, 0);
    rrep(j, 108) {
        set<ll> se;
        rrep(i, 2) {
            if (j >= i) {
                se.insert(grundy[j - i]);
            }
        }

        ll g = 0;
        while (se.count(g)) {
            g++;
        }
        grundy[j] = g;
    }

    ll game = 0;
    rep(i, N) {
        map<ll, ll> ma = soinsu(M[i]);
        for (auto x : ma) {
            game ^= grundy[x.second];
        }
    }

    if (game) {
        cout << "Alice" << endl;
    }

    else {
        cout << "Bob" << endl;
    }
}
0