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