結果

問題 No.7 プライムナンバーゲーム
ユーザー testestesttestestest
提出日時 2015-09-09 17:51:29
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 334 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 6,952 KB
最終ジャッジ日時 2024-04-09 03:49:37
合計ジャッジ時間 1,108 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 6 ms
6,944 KB
testcase_03 AC 1 ms
6,948 KB
testcase_04 AC 1 ms
6,948 KB
testcase_05 AC 1 ms
6,948 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 0 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 3 ms
6,952 KB
testcase_13 AC 4 ms
6,948 KB
testcase_14 AC 6 ms
6,948 KB
testcase_15 AC 6 ms
6,944 KB
testcase_16 AC 5 ms
6,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 | scanf("%d",&n);
      | ^~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int main(){
int primes[1300]={2},w[10001]={};
int n,i,j,s=0;
scanf("%d",&n);
for(i=3;i<=n;i++){
for(j=0;primes[j]*primes[j]<=i;j++)if(i%primes[j]<1)break;
if(i%primes[j])primes[++s]=i;
}
primes[++s]=n+1;
for(i=2;i<=n;i++){
for(s=j=0;primes[j]<=i;j++)s+=w[i-primes[j]];
w[i]=!s;
}
puts(w[n]?"Lose":"Win");
return 0;
}
0