結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
yuho0819
|
| 提出日時 | 2016-09-03 14:02:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 425 bytes |
| コンパイル時間 | 186 ms |
| コンパイル使用メモリ | 23,936 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-15 18:34:02 |
| 合計ジャッジ時間 | 1,004 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d",&a);
| ~~~~~^~~~~~~~~
main.cpp:8:21: warning: iteration 9999 invokes undefined behavior [-Waggressive-loop-optimizations]
8 | k[i]=0;
| ~~~~^~
main.cpp:6:18: note: within this loop
6 | for(i=1;i<=10000;i++){
| ~^~~~~~~
main.cpp:8:21: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ writing 40000 bytes into a region of size 39996 overflows the destination [-Wstringop-overflow=]
8 | k[i]=0;
| ~~~~^~
main.cpp:4:36: note: at offset 4 into destination object ‘k’ of size 40000
4 | int a,s,d,f,g,h[10001],i,j,k[10000];
| ^
ソースコード
#include<stdio.h>
int main(void)
{
int a,s,d,f,g,h[10001],i,j,k[10000];
for(i=1;i<=10000;i++){
h[i]=0;
k[i]=0;
}
k[2]=-1;
k[3]=-1;
h[2]=0;
for(i=2;i<10000;i++){
if(h[i]==0){
for(j=2;j<5000;j++){
if(i*j<=10000)
h[i*j]=1;
}
}
}
for(i=1;i<=10000;i++){
if(h[i]==1){
k[3+i]=1;
k[2+i]=1;
}
}
scanf("%d",&a);
if(k[a]==1)
printf("Lose\n");
if(k[a]==0)
printf("Win\n");
return 0;
}
yuho0819