結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-05 21:26:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,512 bytes |
| コンパイル時間 | 883 ms |
| コンパイル使用メモリ | 89,640 KB |
| 実行使用メモリ | 10,268 KB |
| 最終ジャッジ日時 | 2024-09-24 14:30:42 |
| 合計ジャッジ時間 | 7,146 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 -- * 14 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#define ll long long
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define EPS 1e-14
using namespace std;
// nまでの素数のリストを作成(nを含む)
vector<long long> getPrimeList(int n) {
vector<bool> dp(n + 1, false);
dp[0] = dp[1] = true;
vector<long long> primeList;
for (int i = 2; i < n + 1; ++i) {
if (dp[i]) { continue; }
primeList.push_back(i);
for (int j = i; j < n + 1; j += i) {
dp[j] = true;
}
}
return primeList;
}
bool win(int n, const vector<ll> &primes) {
FOE(p, primes) {
if (n - p > 1) {
if (!win(n - p, primes)) {
return true;
}
}
}
return false;
}
int main(int argc, char *argv[]) {
int N;
cin >> N;
vector<ll> p = getPrimeList(N);
cout << (win(N, p) ? "Win" : "Lose") << endl;
return 0;
}