結果

問題 No.2 素因数ゲーム
コンテスト
ユーザー tana_twtr
提出日時 2014-12-01 19:45:13
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 663 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 553 ms
コンパイル使用メモリ 79,784 KB
実行使用メモリ 1,052,408 KB
最終ジャッジ日時 2026-03-04 10:00:09
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 15 MLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
using namespace std;

struct Stones
{
	int label;
	int count;

	Stones(int l)
		: label(l)
		, count(0)
	{
	}

	Stones(int l, int c)
		: label(l)
		, count(c)
	{
	}
};

int main()
{
	int n;
	cin >> n;

	vector<Stones> stones;
	
	for (int i = 2; i < n; ++i)
	{
		Stones s(i);

		while (n % i == 0)
		{
			++s.count;
			n /= i;
		}

		stones.push_back(s);
	}

	int nim = 0;
	int size = stones.size();

	for (int i = 0; i < size; ++i)
	{
		nim ^= stones[i].count;
	}

	if (nim == 0)
	{
		cout << "Bob" << endl;
	}
	else
	{
		cout << "Alice" << endl;
	}

	return 0;
}
0