結果

問題 No.103 素因数ゲーム リターンズ
ユーザー satake
提出日時 2022-09-13 22:43:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 675 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 196,984 KB
最終ジャッジ日時 2025-02-07 04:52:55
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 710
#endif

vector<int> frac(int x){
	vector<int> ret;
	for(int i = 2; i * i <= x; i++){
		if(x%i == 0){
			int cnt = 0;
			while(x%i == 0){
				cnt++;
				x /= i;
			}
			ret.push_back(cnt);
		}
	}
	if(x != 1) ret.push_back(1);
	return ret;
}

int grundy(vector<int> v){
	int g = 0;
	for(int t: v){
		g ^= (t % 3);
	}
	return g;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> m(n);
	for(auto &x: m) cin >> x;
	int g = 0;
	for(int t: m){
		g ^= grundy(frac(t));
	}
	cout << (g ? "Alice" : "Bob") << endl;
}
0