結果

問題 No.7 プライムナンバーゲーム
ユーザー newlife171128newlife171128
提出日時 2018-01-29 23:40:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 1,122 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 159,472 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:25:16
合計ジャッジ時間 2,372 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,820 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 22 ms
6,948 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 6 ms
6,948 KB
testcase_07 AC 5 ms
6,944 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 9 ms
6,948 KB
testcase_10 AC 1 ms
6,948 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 15 ms
6,948 KB
testcase_13 AC 16 ms
6,944 KB
testcase_14 AC 21 ms
6,944 KB
testcase_15 AC 20 ms
6,948 KB
testcase_16 AC 17 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include "bits/stdc++.h"
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>

#include <string.h>
#include <utility>

typedef long long ll;
#define INF (1e9+1)
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;

typedef pair<int, int> P;

bool prime[100001];

void shieve(int n){

	for(int i=0; i<=n; i++){
		prime[i] = true;;
	}

	for(int i=2; i<=n; i++){
		if(prime[i]){
			for(int j= 2*i; j<=n; j +=i){
				prime[j] =false;
			}
		}
	}
}


bool game[100001];

int main(){

	int n;
	cin>>n;

	shieve(n);

	game[0]  =true;
	game[1] = true;

	for(int i=2; i<=n; i++){

		for(int j=i; j>=2; j--){
			if(prime[j]){

				if(n-j<0){
					break;
				}

				game[i] = !game[i-j];

				if(game[i])break;

				/*cout<<i<<!game[n-j]<<endl;*/
			}
		}
	}

/*	rep(i,16){
		if(game[i]){
			cout<<"win"<<i<<endl;
		}else {
			cout<<"lose"<<i<<endl;
		}
	}*/

	if(game[n]){
		cout<<"Win"<<endl;
	}else {
		cout<<"Lose"<<endl;
	}

}
0