結果

問題 No.103 素因数ゲーム リターンズ
ユーザー pop_o
提出日時 2024-08-30 15:04:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 684 bytes
コンパイル時間 2,001 ms
コンパイル使用メモリ 168,976 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-30 15:04:27
合計ジャッジ時間 3,323 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int g = 0;
        for (int j = 2; j * j <= a[i]; j++) {
            if (a[i] % j == 0) {
                int cnt = 0;
                while (a[i] % j == 0) {
                    a[i] /= j;
                    cnt++;
                }
                g ^= (cnt % 3);
            }
        }
        if (a[i] != 1) g ^= 1;
        ans ^= g;
    }
    cout << (ans == 0 ? "Bob\n": "Alice\n");
}
0