結果

問題 No.7 プライムナンバーゲーム
ユーザー troro_kelptroro_kelp
提出日時 2018-04-24 23:39:38
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,314 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 73,136 KB
実行使用メモリ 7,728 KB
最終ジャッジ日時 2023-09-10 05:01:19
合計ジャッジ時間 7,606 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
using ll = unsigned long long;
const ll mod = 1000000007;
const int M_MAX = 10000;
string al = "abcdefghijklmnopqrstuvwxyz";
//bool less_sec(const pair<int, int>&a, const pair<int, int>&b) {
//	return a.second > b.second;
//}
// << 左シフト(値が大きくなる(*‘ω‘ *))
// >> 右シフト
// 0xFFFFFFFC
bool flag = true;
vector<int> prime;
void dfs(int cnt, int v) {
	if (v < 0) return;
	if (v == 0 || v == 1) {
		if (cnt % 2 == 0) flag = false;
		return;
	}
	for (int i = 0; i < prime.size(); ++i) {
		dfs(cnt + 1, v - prime[i]);
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	prime.push_back(2);
	for (int i = 3; i < n; i += 2) {
		bool judge = true;
		for (int j = 2; j*j <= i; ++j) {
			if (i%j == 0) {
				judge = false;
				break;
			}
		}
		if (judge) prime.push_back(i);
	}
	for (int i = 0; i < prime.size(); ++i) {
		dfs(0, n - prime[i]);
	}
	if (flag) cout << "Win" << endl;
	else cout << "Lose" << endl;
	return 0;
}
0