結果

問題 No.7 プライムナンバーゲーム
ユーザー heno239heno239
提出日時 2018-10-31 09:13:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,559 bytes
コンパイル時間 1,259 ms
コンパイル使用メモリ 112,068 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:33:46
合計ジャッジ時間 1,954 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
bool isp[1 << 14];
vector<int> p;
bool chked[1 << 14];
bool ans[1 << 14];
int len;
void init() {
	fill(isp + 2, isp + (1 << 14),true);
	Rep(i, 2, (1 << 14)) {
		if (!isp[i])continue;
		p.push_back(i);
		for (int j = 2 * i; j < (1<<14); j += i) {
			isp[j] = false;
		}
	}
	chked[0] = chked[1] = true;
	ans[0] = ans[1] = true;
	len = p.size();
}
bool dfs(int n) {
	if (chked[n])return ans[n];
	bool res = false;
	rep(i, len) {
		if (p[i] > n)break;
		if (!dfs(n - p[i])) {
			res = true; break;
		}
	}
	chked[n] = true;
	return ans[n] = res;
}
int n;
int main(){
	cin >> n;
	init();
	if (dfs(n))cout << "Win" << endl;
	else cout << "Lose" << endl;
	return 0;
}
0