結果

問題 No.7 プライムナンバーゲーム
ユーザー HAHAHAHAHAHA
提出日時 2016-08-10 10:31:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 1,217 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 85,932 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:01:59
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<utility>
#include <fstream>
#include<set>
#include<map>
#include<cctype>
#include<cmath>
#include<algorithm>
#include <numeric>
using namespace std;


#define RALL(x) (x).rbegin(),(x).rend()
#define ALL(x) (x).begin(),(x).end()
#define repp(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define clr(a) memset((a), 0 ,sizeof(a))
#define found(s,e) ((s).find(e)!=(s).end())

typedef pair<int,int> P;
typedef vector<pair<int,int> > pii;
typedef map<string,int> mdi;



bool memo[10010];
bool dp[10010];

vector<int> isprime(){
	vector<int> prime;
	for(int i=2;i<10010;i++){
		if(memo[i]) continue;
			prime.push_back(i);
		for(int j=i+i;j<10010;j+=i){
			memo[j]=true;
		}
	}
	return prime;
}


int main(){
	vector<int> prime=isprime();
	int n;
	cin >> n;
	dp[0]=dp[1]=true;
	for(int i=2;i<=n;i++){
		for(int j=0;j<prime.size();j++){
			if(i-prime[j]<0) break;
			dp[i] |= !dp[i-prime[j]];
		}
	}
	if(dp[n]) cout << "Win" << endl;
	else cout << "Lose" << endl;
	return 0;
}
0