結果

問題 No.7 プライムナンバーゲーム
ユーザー obaoba
提出日時 2015-01-09 00:13:35
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 737 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 64,104 KB
実行使用メモリ 814,608 KB
最終ジャッジ日時 2023-09-03 22:46:28
合計ジャッジ時間 7,880 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘bool roop(int, int)’:
main.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

ソースコード

diff #

#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;
}
0