結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
|
提出日時 | 2014-11-25 01:23:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 421 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 23,552 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 15:28:30 |
合計ジャッジ時間 | 766 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include <stdio.h> #define M 10000 int table[M+1],primes[M/2],result[M+1]; int main(){ int i,j,n; table[0]=table[1]=result[0]=result[1]=1; for(i=2;i<=M;i++)if(!table[i])for(j=2*i;j<=M;j+=i)table[j]=1; for(n=0,i=2;i<=M;i++)if(!table[i])primes[n++]=i; for(i=2;i<=M;i++)for(j=0;j<n&&primes[j]<=i;j++)if(!result[i-primes[j]]){result[i]=1;break;} scanf("%d",&n); puts(result[n]?"Win":"Lose"); return 0; }