結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2015-11-23 21:02:56 |
言語 | C90 (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 454 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 20,736 KB |
実行使用メモリ | 13,760 KB |
最終ジャッジ日時 | 2024-09-13 17:18:09 |
合計ジャッジ時間 | 6,865 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 TLE * 1 -- * 29 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:10:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d", &n); | ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(){ int n; int now=1, now_tmp; int d; int back_point; int move_cnt=1; scanf("%d", &n); while(now!=n){ d=0; now_tmp=now; while(now_tmp>0){ if(now_tmp%2==1) ++d; now_tmp/=2; } if(now+d<=n)now+=d; else{ back_point=now; now-=d; } if(now==back_point){ printf("-1\n"); return 0; } ++move_cnt; } printf("%d\n", move_cnt); return 0; }