結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | hitoyozake |
提出日時 | 2018-06-03 10:16:29 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,467 bytes |
コンパイル時間 | 907 ms |
コンパイル使用メモリ | 85,560 KB |
実行使用メモリ | 4,508 KB |
最終ジャッジ日時 | 2023-09-12 21:45:31 |
合計ジャッジ時間 | 2,070 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
4,384 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 3 ms
4,380 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 26 ms
4,380 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 41 ms
4,380 KB |
testcase_15 | AC | 42 ms
4,380 KB |
testcase_16 | WA | - |
ソースコード
#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; }