結果

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

テストケース

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

ソースコード

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));

		if( count(y.begin(),y.end(),x[i]) >= 1 ){	
			y.erase(find(y.begin(),y.end(),x[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;
	}

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