結果

問題 No.7 プライムナンバーゲーム
ユーザー OnjuOnju
提出日時 2015-02-07 05:12:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 63,664 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 14:55:32
合計ジャッジ時間 1,365 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#define N_MAX 10000
using namespace std;

vector<int>* CalPrime()
{
	bool list[N_MAX + 1];
	auto prime = new vector<int>();
	int sqrtnmax = sqrt(N_MAX);

	for (int i = 2; i <= N_MAX; ++i)
		list[i] = true;

	for (int i = 2; i <= sqrtnmax; ++i)
	{
		if (list[i])
		{
			int jmax = N_MAX / i;
			for (int j = i; j <= jmax; ++j)
				list[i*j] = false;
		}
	}

	for (int i = 2, p = 0; i <= N_MAX; ++i)
	{
		if (list[i])
			prime->push_back(i);
	}

	return prime;
}

int main()
{
	auto prime = CalPrime();

	int N;
	cin >> N;

	int temp = N, count = 0;
	for (auto it = prime->rbegin(); it != prime->rend(); ++it)
	{
		if (*it < temp - 1)
		{
			temp -= *it;
			++count;
		}
	}

	if (count & 1)
		cout << "Win" << endl;
	else
		cout << "Lose" << endl;

	delete prime;

	return 0;
}
0