結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
![]() |
提出日時 | 2014-11-29 20:04:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 876 bytes |
コンパイル時間 | 1,689 ms |
コンパイル使用メモリ | 158,292 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-11 07:24:53 |
合計ジャッジ時間 | 2,259 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 4 |
コンパイルメッセージ
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 * 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; }