結果

問題 No.7 プライムナンバーゲーム
ユーザー 👑 yumechiyumechi
提出日時 2016-03-14 23:54:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,340 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 77,008 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 11:23:30
合計ジャッジ時間 1,804 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<30
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

bool dp[10010];

vector<int> getPrime(int n) {
	vector<int> ret;

	// errro check
	if(n <= 0) {
		cout << "can use this method negative number: getPrime " << n << endl;
		return ret;
	}

	FOR(i, 2, n) {
		bool flag = true;
		for(auto prime : ret) {
			if(i % prime == 0) {
				flag = false;
				break;
			}
		}

		if(flag) ret.pb(i);
	}

	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.precision(16);

	int n;
	cin >> n;

	auto prime = getPrime(10000);

	dp[0] = dp[1] = dp[2] = dp[3] = false;
	dp[4] = dp[5] = true;
	REP(i, n) {
		for(auto j : prime) {
			if(i < j) break;
			dp[j] = dp[i-j];
		}
	}

	cout << (dp[n] ? "Win" : "Lose") << endl;
	return 0;
}
0