結果

問題 No.7 プライムナンバーゲーム
ユーザー sekiya9311sekiya9311
提出日時 2016-05-20 17:28:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 1,341 bytes
コンパイル時間 2,382 ms
コンパイル使用メモリ 107,880 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 03:59:26
合計ジャッジ時間 2,626 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;
bool isPrime(long a){
	if(a<2) return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0) return false;
	}
	return true;
}

int main(){
	vector<int> p;
	int N; cin>>N;
	REP(i,N) if(isPrime(i+1)) p.push_back(i+1);
	vector<bool> dp(N+1,false);
	dp[0]=true; dp[1]=true;
	FOR(i,2,N+1){
		REP(j,p.size()){
			if(i<p[j]) break;
			dp[i]=dp[i]|(!dp[i-p[j]]);
		}
	}
	string s;
	if(dp[N]) s="Win";
	else s="Lose";
	cout<<s<<endl;
}
0