結果

問題 No.7 プライムナンバーゲーム
ユーザー DadarithmDadarithm
提出日時 2015-10-04 21:25:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 59,532 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-09-27 02:02:23
合計ジャッジ時間 7,048 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

bool prime(int n)
{
	if (n < 2)
		return false;

	for (int i = 2; i <= sqrt(n); ++i)
	{
		if (n % i == 0)
			return false;
	}
	return true;
}

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

	bool ans = false;
	while (1)
	{
		if (res == 2)
		{
			ans != ans;
			break;
		}
		else if (res < 2)
			break;

		for (int i = 2; 1 < res - i; ++i)
		{
			if (prime(res - i))
			{
				res = i;
				break;
			}
		}
		ans = !ans;
	}

	cout << (ans ? "Win" : "Lose" ) << endl;

	return 0;
}
0