結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
Irmystp
|
| 提出日時 | 2014-11-29 20:05:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 872 bytes |
| コンパイル時間 | 1,047 ms |
| コンパイル使用メモリ | 157,016 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-11 07:24:56 |
| 合計ジャッジ時間 | 1,643 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool isprime[10001];
int prime[5001];
int lim = 0;
void eratosthenes(void){
fill(isprime, isprime+10001, true);
isprime[0] = isprime[1] = false;
for(int x = 2; x <= 10000; x++){
if(isprime[x]){
prime[lim++] = x;
for(int y = x * x; y <= 10000; y += x) isprime[y] = false;
}
}
}
int N;
bool win[10001];
int main(){
eratosthenes();
scanf("%d", &N);
fill(win, win+N+1, false);
win[0] = win[1] = true;
for(int x = 2; x <= N; x++){
win[x] = false;
for(int y = 0; prime[y] <= x; y++){
if(!win[x-prime[y]]){
win[x] = true;
break;
}
}
}
if(win[N]){
puts("Win");
}else{
puts("Lose");
}
return 0;
}
Irmystp