結果
| 問題 | No.103 素因数ゲーム リターンズ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-07-14 00:44:21 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 33 ms / 5,000 ms | 
| コード長 | 2,363 bytes | 
| コンパイル時間 | 1,201 ms | 
| コンパイル使用メモリ | 131,488 KB | 
| 最終ジャッジ日時 | 2025-01-11 20:23:21 | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 20 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:81:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   81 |     int n; scanf("%d", &n);
      |            ~~~~~^~~~~~~~~~
main.cpp:82:56: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   82 |     vector<int> a(n); for (int i = 0; i < n; i++) scanf("%d", &a[i]);
      |                                                   ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
constexpr long long MAX = 51000;
bool IsPrime[MAX];
ll MinFactor[MAX]; vector<ll> preprocess(ll n = MAX) {
    vector<ll> res;
    for (ll i = 0; i < n; ++i) IsPrime[i] = true, MinFactor[i] = -1;
    IsPrime[0] = false; IsPrime[1] = false;
    MinFactor[0] = 0; MinFactor[1] = 1;
    for (ll i = 2; i < n; ++i) {
        if (IsPrime[i]) {
            MinFactor[i] = i;
            res.push_back(i);
            for (ll j = i * 2; j < n; j += i) {
                IsPrime[j] = false;
                if (MinFactor[j] == -1) MinFactor[j] = i;
            }
        }
    }
    return res;
}
vector<pair<ll, ll> > fast_prime_factor(ll n) {
    vector<pair<ll, ll> > res;
    while (n != 1) {
        ll prime = MinFactor[n];
        ll exp = 0;
        while (MinFactor[n] == prime) {
            ++exp;
            n /= prime;
        }
        res.push_back(make_pair(prime, exp));
    }
    return res;
}
int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */
    preprocess();
    int n; scanf("%d", &n);
    vector<int> a(n); for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    int all_xor = 0;
    for (int i = 0; i < n; i++) {
        auto fp = fast_prime_factor(a[i]);
        for (auto p : fp) {
            int cnt = p.second;
            all_xor ^= cnt % 3;
        }
    }
    if (all_xor) puts("Alice");
    else puts("Bob");
    return 0;
}
            
            
            
        