結果
| 問題 | No.3 ビットすごろく | 
| コンテスト | |
| ユーザー |  tsukacchan | 
| 提出日時 | 2016-06-03 10:42:31 | 
| 言語 | C90 (gcc 12.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 556 bytes | 
| コンパイル時間 | 431 ms | 
| コンパイル使用メモリ | 20,480 KB | 
| 実行使用メモリ | 6,528 KB | 
| 最終ジャッジ日時 | 2024-10-08 06:10:15 | 
| 合計ジャッジ時間 | 6,734 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 TLE * 1 -- * 30 | 
コンパイルメッセージ
main.c: In function ‘main’:
main.c:13:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 | scanf("%d",&N);
      | ^~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
int bit_count(int);
int main(void){
    
int N;
int location=1; //現在のマスの位置
int bit=0;      // 何ビット進むかor戻るか
int sum;		
int times=1;    //移動回数
scanf("%d",&N);
while(location != N){
bit = bit_count(location);
sum = location + bit;
if(sum <= N) 
location += bit;
else
location -= bit;
times++;
sum=0;
}
printf("%d",times);
return 0;   
    
}
int bit_count(int n)
{
int bit_counter=0;
    while(n>=1)
    {
    if(n%2==1)
    bit_counter++;
    n=n/2;
    }
return bit_counter;
}
            
            
            
        