結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
hitoyozake
|
| 提出日時 | 2018-06-03 10:12:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,399 bytes |
| コンパイル時間 | 931 ms |
| コンパイル使用メモリ | 94,488 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 09:14:14 |
| 合計ジャッジ時間 | 2,072 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 12 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
int main()
{
int n = 0;
std::cin >> n;
//邏�謨ー繧呈アゅa繧�
std::vector<int> primes;
std::vector<int> tmp(n-2, 0);
for(int i = 2; i < n; ++i )
{
tmp.push_back(i);
}
for( int i = 2; i < n; ++i )
{
primes.push_back(i);
if(std::sqrt(n) <= i)
break;
std::vector<int> t;
for(auto x: tmp){
if(x%i != 0){
t.push_back(x);
}
}
tmp = t;
}
for(auto x: tmp){
primes.push_back(x);
}
//蜍昴■雋�縺僧ap繧剃ス懊k
std::map<int, bool> winlose;
winlose[0] = false;
winlose[1] = false;
for( int i = 2; i < n; ++i ){
winlose[i] = false;
for( auto const prime: primes)
{
if(prime > i ){
break;
}
if(i-prime >= 2&& winlose[i-prime]==false){
winlose[i] = true;
break;
}
}
}
/*
for(auto i: winlose){
std::cout << "winlose[ " << i.first << " ]: " << i.second << std::endl;
}*/
std::string wl = "Win";
if(winlose[n]==false)
wl = "Lose";
std::cout << wl << std::endl;
return 0;
}
hitoyozake