結果

問題 No.7 プライムナンバーゲーム
ユーザー sggkshiosggkshio
提出日時 2016-10-30 03:28:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 832 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 84,276 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:03:24
合計ジャッジ時間 1,532 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>



using namespace std;


bool f[10008];
bool F[10008];

int main() {

	vector<int>p;
	p.push_back(2);
	for(int i=3;i<10001;i+=2){
		f[i]=1;
		for(int j=3;j*j<=i;j++){
			if(i%j==0){
				f[i]=0;
				break;
			}
		}
		if(f[i])p.push_back(i);
	}
	f[2]=1;
	
	int n;
	cin>>n;
	for(int i=0;i<=n;i++)
		F[i]=1;
	for(int i=3;i<=n;i++){
		int r=0;
		while(p.size()>r){
			
			if(p[r]>=i)break;
			if(i-p[r]<=1)break;
			if(F[i-p[r]]==1){
				F[i]=0;break;
			}
			r++;
		}
		//cout<<F[i];
	}
	if(F[n]==0)cout<<"Win"<<endl;
	else cout<<"Lose"<<endl;

	return 0;
}


	
0