結果

問題 No.7 プライムナンバーゲーム
ユーザー chakkuchakku
提出日時 2015-10-17 16:59:48
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,187 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 70,624 KB
実行使用メモリ 7,756 KB
最終ジャッジ日時 2023-09-29 16:11:51
合計ジャッジ時間 8,752 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
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 <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,x,n) for(ll i=x;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x<<":"<<#y<<"=="<<x<<":"<<y<<endl
const int INF = INT_MAX / 3;
const int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 };
#define MOD 1000000007
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;

int N;
bool sosu[10001];

//meが0で先手,1で後手。nは受け取る数
bool rec(int me,int n){
	if (n == 0 || n == 1) return true;
	int next = (me + 1) % 2;
	for (int i = 0; i < n; i++){
		if (sosu[i]){
			if (!rec(next, n - i)) return true;
		}
	}
	return false;
}

int main(){
	cin >> N;
	rep(i, 10001) sosu[i] = true;
	sosu[0] = false;
	sosu[1] = false;
	for (int i = 2; i <= sqrt(10001); i++){
		if (sosu[i]){
			for (int j = i * 2; j < 10001; j += i){
				sosu[j] = false;
			}
		}
	}
	if (rec(0, N)){
		cout << "Win" << endl;
	} else{
		cout << "Lose" << endl;
	}
	return 0;
}
0