結果

問題 No.103 素因数ゲーム リターンズ
ユーザー kazumakazuma
提出日時 2017-04-25 19:53:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 612 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 175,676 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 09:59:40
合計ジャッジ時間 3,117 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int dp[100];

void grundy() {
	for (int i = 1; i < 100; i++) {
		set<int> s;
		for (int j = max(0, i - 2); j < i; j++) {
			s.insert(dp[j]);
		}
		int res = 0;
		while (s.count(res)) res++;
		dp[i] = res;
	}
}

int main()
{
	grundy();
	int N, M;
	cin >> N;
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> M;
		map<int, int> v;
		for (int j = 2; j * j <= M; j++) {
			while (M % j == 0) {
				M /= j;
				v[j]++;
			}
		}
		if (M != 1) {
			v[M]++;
		}
		for (auto n : v) {
			res ^= dp[n.second];
		}
	}
	cout << (res ? "Alice" : "Bob") << endl;
	return 0;
}
0