結果

問題 No.3 ビットすごろく
ユーザー satanicsatanic
提出日時 2015-11-23 21:54:39
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 24,504 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 18:24:33
合計ジャッジ時間 1,365 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,352 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 0 ms
4,352 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,348 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0