結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2016-12-26 12:04:08 |
言語 | C90 (gcc 12.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 536 bytes |
コンパイル時間 | 307 ms |
コンパイル使用メモリ | 20,864 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-14 23:33:55 |
合計ジャッジ時間 | 4,357 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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==0) return 0; 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){ t=0; 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){ if(!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; }