結果

問題 No.7 プライムナンバーゲーム
ユーザー tkm2261
提出日時 2017-07-03 23:45:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 840 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 161,068 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-01 16:05:08
合計ジャッジ時間 1,983 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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; }
    }
  }
  string s = dp[N]?"Win":"Lose";
  cout << s << endl;
}
0