結果

問題 No.7 プライムナンバーゲーム
ユーザー sigma425sigma425
提出日時 2015-04-25 09:29:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 871 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 152,104 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-24 20:20:14
合計ジャッジ時間 3,165 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 137 ms
4,380 KB
testcase_03 AC 12 ms
4,376 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 44 ms
4,380 KB
testcase_07 AC 31 ms
4,380 KB
testcase_08 AC 16 ms
4,376 KB
testcase_09 AC 64 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 32 ms
4,380 KB
testcase_12 AC 99 ms
4,376 KB
testcase_13 AC 105 ms
4,380 KB
testcase_14 AC 135 ms
4,380 KB
testcase_15 AC 127 ms
4,376 KB
testcase_16 AC 118 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
const ll ccc=10000;
bool prime[ccc+1];
vector<ll> pr;
void makeprime(){
	ll i,j;
	for(i=2;i<=ccc;i++) prime[i]=true;
	for(i=2;i*i<=ccc;i++) if(prime[i]) for(j=2;j*i<=ccc;j++) prime[j*i]=false;
	for(i=2;i<=ccc;i++) if(prime[i]) pr.push_back(i);
}
int g[10001];
int main(){
	makeprime();
	int N;
	cin>>N;
	for(int i=2;i<=N;i++){
		set<int> st;
		for(int p:pr){
			if(i-p<2) break;
			st.insert(g[i-p]);
		}
		int v=0;
		while(binary_search(all(st),v)) v++;
		g[i]=v;
	}
	if(g[N]) puts("Win");
	else puts("Lose");
}
0