結果

問題 No.7 プライムナンバーゲーム
ユーザー chakku
提出日時 2015-10-17 16:59:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 1,187 bytes
コンパイル時間 869 ms
コンパイル使用メモリ 72,952 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-22 10:17:59
合計ジャッジ時間 7,382 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

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