結果

問題 No.103 素因数ゲーム リターンズ
ユーザー Outing_IslandOuting_Island
提出日時 2022-01-23 20:45:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,910 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 169,724 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 02:51:49
合計ジャッジ時間 2,684 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// Check Overflow
#ifdef DEBUG_BUILD
#define _GLIBCXX_DEBUG
#endif

// include
#include <bits/stdc++.h>

// Debugger
#ifdef DEBUG_BUILD
#include "debugger.hpp"
#else
#define debug(...)
#define debugdo(...)
#define debugtab(...)
#endif

// for alias
#define range(i, A, B) for (ll i = (ll)(A); i < (ll)(B); i++)
#define rep(i, N) range(i, 0, N)
#define rrep(i, N) for (ll i = (ll)(N)-1; i >= 0; i--)

// type alias
using namespace std;
using ll = long long;
using ld = long double;
using pll = std::pair<ll, ll>;
template <class T>
using vec = std::vector<T>;
template <class T>
using vec2 = std::vector<vec<T>>;
template <class T>
using vec3 = std::vector<vec2<T>>;
template <class T>
using priority_greater_queue = priority_queue<T, vector<T>, greater<T>>;

// number alias
constexpr int MOD = 1000000007;
constexpr ll INFL = std::numeric_limits<ll>::max() / 4;
constexpr array<ll, 4> DX = {1, 0, -1, 0};
constexpr array<ll, 4> DY = {0, 1, 0, -1};

// new vector
template <class T>
vec2<T> newVec2(size_t A, size_t B, ll a = T()) { return vec2<T>(A, vec<T>(B, a)); }
template <class T>
vec3<T> newVec3(size_t A, size_t B, size_t C, ll a = T()) { return vec3<T>(A, vec2<T>(B, vec<T>(C, a))); }

// vector input
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &data)
{
    for (T &in : data)
    {
        is >> in;
    }
    return is;
}

// functions
template <class T>
bool chmax(T &a, const T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T pow(T x, T n)
{
    T ret = 1;
    while (n > 0)
    {
        if (n & 1)
            ret *= x;
        x *= x;
        n >>= 1;
    }
    return ret;
}
/*****/

// 素因数分解する O(sprt(n))
vector<pair<long long, long long>> prime_factorize(long long n)
{
    vector<pair<long long, long long>> res;
    for (long long i = 2; i * i <= n; ++i)
    {
        if (n % i != 0)
            continue;
        long long ex = 0; // 指数
        while (n % i == 0)
        {
            ++ex;
            n /= i;
        }
        res.push_back({i, ex});
    }
    if (n != 1)
        res.push_back({n, 1});
    return res;
}

void Main()
{
    ll N;
    cin >> N;
    vec<ll> M(N);
    cin >> M;

    ll grundy = 0;
    rep(i, N)
    {
        auto F = prime_factorize(M[i]);
        ll g = 0;
        rep(j, F.size())
        {
            g ^= F[j].second % 3;
        }

        grundy ^= g;
    }

    cout << (grundy != 0 ? "Alice" : "Bob") << endl;
}

/*****/

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    std::cerr << std::fixed << std::setprecision(10);
    Main();
    std::cout << std::flush;
    std::cerr << "--end--" << std::flush;
    return 0;
}
0