結果

問題 No.7 プライムナンバーゲーム
ユーザー tkm2261tkm2261
提出日時 2017-07-03 23:44:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 2,417 ms
コンパイル使用メモリ 159,624 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 14:51:03
合計ジャッジ時間 2,682 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

int arr[10010];
int dp[10001];

int N, t, s = 0;

void Eratosthenes(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
}

int main(){

	cin >> N;
  Eratosthenes();
  dp[0] = dp[1] = 1;
  FOR(i, 2, N + 1){
    FOR(j, 2, N) {
      if(j > i) break;
      if(dp[i - j]==0 && arr[j]){ dp[i] = 1; break; }
    }
  }
  cout << dp[N] << endl;
  string s = dp[N]?"Win":"Lose";
  cout << s << endl;
}
0