結果
| 問題 | 
                            No.3 ビットすごろく
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-03-31 02:29:28 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 700 bytes | 
| コンパイル時間 | 2,247 ms | 
| コンパイル使用メモリ | 76,940 KB | 
| 実行使用メモリ | 57,900 KB | 
| 最終ジャッジ日時 | 2024-10-02 08:20:12 | 
| 合計ジャッジ時間 | 9,039 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 2 TLE * 1 -- * 30 | 
ソースコード
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
		
		int cnt, cnt1;
		int move=1;
		int num=1;
		int check=0;
		
		int i = sc.nextInt(); //マス目を入力する
		
		System.out.println("1");
		
		while(num!=i){
					cnt = Integer.bitCount(num); //1の数を数える
					num += cnt;
				if(num>i){
						num = num-cnt;
						cnt = Integer.bitCount(num); //1の数を数える
						num = num-cnt;
						}
					move++;
					System.out.println("=>"+num);
				}
		System.out.println(move+"回移動しました");
    }
}