結果

問題 No.103 素因数ゲーム リターンズ
ユーザー kyuridenamidakyuridenamida
提出日時 2014-12-15 00:03:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 84,244 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 14:34:08
合計ジャッジ時間 1,905 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <set>
using namespace std;

map< vector<int> , int> dp;
vector<int> factor(int n){
	vector<int> ret;
 
	int i = 2;
	while(i*i<=n){
		if(n%i==0)ret.push_back(i) , n/=i , i = 2;
		else i++;
	}
	if(n!=1)ret.push_back(n);
	
	return ret;
}

int dfs(vector<int> x){
	if( x.size() == 0 ) return 0;
	if( dp.count(x) ) return dp[x];
	set<int> g;
	
	for(int i = 0 ; i < x.size() ; i++){
		vector<int> y = x;
		y.erase(y.begin()+i);
		g.insert(dfs(y));
	}
	int ans = 0;
	while(g.count(ans))ans++;
	return dp[x] = ans;
}
int main(){
	int n;
	cin >> n;
	int x = 0;
	int cnt = 0;
	for(int i = 0 ; i < n ; i++){
		int a; cin >> a;
		int s = dfs(factor(a));
		x ^= s;
		if( s == 1 ) cnt++;
	}
	int r = 0;
	if( cnt == 0 && x == 0 ) r = 1;
	else if( cnt == 1 ) r = 1;
	else if( cnt > 1 && x != 0 ) r = 1;
	else r = 0;

	cout << (r ? "Alice" : "Bob" ) << endl;
}
0