結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-11 14:38:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 130 ms / 5,000 ms |
| コード長 | 1,069 bytes |
| コンパイル時間 | 854 ms |
| コンパイル使用メモリ | 96,680 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-01 15:28:55 |
| 合計ジャッジ時間 | 2,363 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
void findPrime(int N, vector<bool>& isPrime)
{
isPrime.assign(N+1, true);
isPrime[0] = isPrime[1] = false;
for(int i=2; i*i<=N; i++){
if(isPrime[i]){
for(int j=i; i*j<=N; j++){
isPrime[i*j] = false;
}
}
}
}
int main()
{
int n;
cin >> n;
vector<bool> isPrime;
findPrime(n, isPrime);
vector<bool> dp(n+1, false);
dp[0] = dp[1] = false;
for(int i=2; i<=n; ++i){
for(int j=2; j<=i-2; ++j){
if(isPrime[j] && !dp[i-j])
dp[i] = true;
}
}
if(dp[n])
cout << "Win" << endl;
else
cout << "Lose" << endl;
return 0;
}