結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,812 KB
testcase_01 WA -
testcase_02 AC 117 ms
55,664 KB
testcase_03 AC 120 ms
55,984 KB
testcase_04 WA -
testcase_05 AC 117 ms
55,776 KB
testcase_06 AC 117 ms
55,984 KB
testcase_07 AC 118 ms
55,912 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 118 ms
55,888 KB
testcase_13 AC 117 ms
55,628 KB
testcase_14 AC 120 ms
55,864 KB
testcase_15 AC 127 ms
55,756 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 118 ms
55,648 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 116 ms
55,860 KB
testcase_22 AC 116 ms
55,676 KB
testcase_23 AC 116 ms
55,672 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 118 ms
56,116 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
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) {
                ans = -1;
                break;
            }
            ans++;
        }

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