結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
![]() |
提出日時 | 2018-06-03 10:16:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,467 bytes |
コンパイル時間 | 951 ms |
コンパイル使用メモリ | 85,768 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 09:14:55 |
合計ジャッジ時間 | 1,704 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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: primes) std::cout << i << std::endl; 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; }