結果

問題 No.7 プライムナンバーゲーム
ユーザー Unbakedbread
提出日時 2025-08-07 00:01:23
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 469 bytes
コンパイル時間 3,261 ms
コンパイル使用メモリ 279,204 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-07 00:01:27
合計ジャッジ時間 4,420 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
	int N;cin>>N;
	
	vector<bool> is_prime(N+1,true);
	vector<int> primes;
	for(int i=2;i<=N;i++){
		if(!is_prime[i]) continue;
		primes.push_back(i);
		for(int j=i*2;j<=N;j+=i) is_prime[j]=false;
	}
	
	vector<bool> g(N+1,false);
	g[0]=g[1]=true;
	for(int i=2;i<=N;i++){
		for(auto p:primes){
			if(i<p) break;
			if(!g[i-p]){
				g[i]=true;
				break;
			}
		}
	}
	
	cout<<(g[N]?"Win":"Lose")<<"\n";
	return 0;
}
0