結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-26 11:59:55 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 513 bytes |
| コンパイル時間 | 369 ms |
| コンパイル使用メモリ | 20,992 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-14 23:29:16 |
| 合計ジャッジ時間 | 4,708 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 RE * 24 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d",&n);;
| ^~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
int bit(int a){
if(a==1) return 1;
return a%2+bit(a/2);
}
int s,n,i,next[10000],f[10000],t=1,p,tt;
int main(){
scanf("%d",&n);;
while(i<t){
tt=t;
for(;i<t;i++){
f[next[i]]=1;
if(next[i]==n-1){
tt=0;
break;
}
p=bit(next[i]+1);
if(next[i]+p<n){
if(!f[next[i]+p]){
next[tt]=next[i]+p;
tt++;
}
}
if(next[i]-p>=0 && !f[next[i]-p]){
next[tt]=next[i]-p;
tt++;
}
}
t=tt;
s++;
}
if(f[n-1]==0) s=-1;
printf("%d\n",s);
return 0;
}