結果

問題 No.3 ビットすごろく
ユーザー n_gojon_gojo
提出日時 2020-04-10 16:28:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 3,525 ms
コンパイル使用メモリ 73,328 KB
実行使用メモリ 58,188 KB
最終ジャッジ日時 2023-10-13 07:23:49
合計ジャッジ時間 9,374 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,112 KB
testcase_01 AC 122 ms
55,904 KB
testcase_02 AC 123 ms
55,976 KB
testcase_03 AC 127 ms
55,952 KB
testcase_04 AC 124 ms
53,592 KB
testcase_05 AC 127 ms
55,684 KB
testcase_06 AC 128 ms
55,816 KB
testcase_07 AC 123 ms
55,852 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 126 ms
56,236 KB
testcase_13 AC 130 ms
55,776 KB
testcase_14 AC 126 ms
55,680 KB
testcase_15 AC 128 ms
55,696 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 123 ms
55,856 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 121 ms
55,640 KB
testcase_22 AC 128 ms
55,776 KB
testcase_23 AC 126 ms
55,848 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 121 ms
55,840 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 125 ms
55,576 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No3 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int ans = 1;
        int bid = 1;
        while (bid != n) {
            int i = bid;
            int s = 0;
            while (i > 0) {
                s += i%2;
                i/=2;
            }
            bid+=s;
            if (bid > n) {
                bid -= s*2;
            }
            ans++;
            if (ans == 10000) {
                ans = -1;
                break;
            }
        }

        System.out.println(ans);
    }
}
0