結果

問題 No.103 素因数ゲーム リターンズ
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-09 20:51:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 775 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 152,556 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 19:06:28
合計ジャッジ時間 3,464 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define MAX 10005

int dp[MAX];
vector<int> prime;

bool isprime(int a){
	for (int i = 2; i * i <= a; i++)
	{
		if (a%i == 0) return false;
	}
	return true;
}

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	dp[1] = 0;

	for (int i = 2; i < MAX; i++)
	{
		if (isprime(i)) prime.push_back(i);
	}
	for (int i = 2; i < MAX; i++)
	{
		int temp = i;
		set<int> s;
		for (int j: prime)
		{
			if (i%j == 0){
				s.insert(dp[i / j]);
				if (i % (j*j) == 0){
					s.insert(dp[i / j / j]);
				}
			}
		}
		while (s.count(dp[i])) dp[i]++;
	}
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans ^= dp[A[i]];
	}
	if (ans == 0) cout << "Bob" << endl;
	else cout << "Alice" << endl;
}


0