結果

問題 No.7 プライムナンバーゲーム
ユーザー Onju
提出日時 2015-02-07 05:12:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 65,512 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 10:32:35
合計ジャッジ時間 1,232 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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