結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
![]() |
提出日時 | 2015-01-09 00:13:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 737 bytes |
コンパイル時間 | 589 ms |
コンパイル使用メモリ | 63,468 KB |
実行使用メモリ | 814,720 KB |
最終ジャッジ日時 | 2024-06-13 03:24:20 |
合計ジャッジ時間 | 6,655 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 MLE * 1 -- * 15 |
コンパイルメッセージ
main.cpp: In function ‘bool roop(int, int)’: main.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type] 23 | } | ^
ソースコード
#include <iostream> #include <algorithm> #include <vector> #define REP(a,b) for(int a=0; a<(int)b; a++) using namespace std; int N; vector <int> sosuu; bool roop(int num, int turn){ if(num == 0 || num == 1) return (turn == 1)? false : true; REP(i, sosuu.size()){ if(turn == 0){ if(num-sosuu[i] < 0) return false; if(roop(num-sosuu[i], turn^1)) return true; }else{ if(num-sosuu[i] < 0) return true; if(!roop(num-sosuu[i], turn^1)) return false; } } } int main(){ cin >> N; for(int i=2; i<=N; i++){ bool flag = true; REP(j,sosuu.size()){ if(i%sosuu[j] == 0){ flag = false; break;} } if(flag) sosuu.push_back(i); } if(roop(N,0)) cout << "Win" << endl; else cout << "Lose" << endl; return 0; }