結果
問題 | No.3 ビットすごろく |
ユーザー | Taka |
提出日時 | 2016-03-31 02:29:28 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 700 bytes |
コンパイル時間 | 1,891 ms |
コンパイル使用メモリ | 76,584 KB |
実行使用メモリ | 73,176 KB |
最終ジャッジ日時 | 2024-04-10 06:40:00 |
合計ジャッジ時間 | 8,882 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | TLE | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
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+"回移動しました"); } }