結果

問題 No.103 素因数ゲーム リターンズ
ユーザー data9824
提出日時 2015-06-24 01:38:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 743 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 72,380 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 17:18:38
合計ジャッジ時間 1,226 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> m(n);
	for (int i = 0; i < n; ++i) {
		cin >> m[i];
	}
	vector<int> numbers;
	for (int i = 0; i < n; ++i) {
		int x = m[i];
		map<int, int> factors;
		for (int divisor = 2; divisor * divisor <= x; ++divisor) {
			while (x % divisor == 0) {
				x /= divisor;
				++factors[divisor];
			}
		}
		if (x > 1) {
			++factors[x];
		}
		for (map<int, int>::const_iterator it = factors.begin();
			it != factors.end();
			++it) {
			numbers.push_back(it->second);
		}
	}
	int grundy = 0;
	for (size_t i = 0; i < numbers.size(); ++i) {
		grundy ^= (numbers[i] % 3);
	}
	cout << (grundy == 0 ? "Bob" : "Alice") << endl;
	return 0;
}
0