結果

問題 No.253 ロウソクの長さ
ユーザー KilisameKilisame
提出日時 2016-09-30 16:02:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 962 bytes
コンパイル時間 3,755 ms
コンパイル使用メモリ 74,600 KB
実行使用メモリ 74,256 KB
平均クエリ数 23.11
最終ジャッジ日時 2023-09-23 11:34:51
合計ジャッジ時間 11,988 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
72,192 KB
testcase_01 AC 158 ms
71,668 KB
testcase_02 AC 154 ms
70,424 KB
testcase_03 AC 157 ms
71,744 KB
testcase_04 AC 158 ms
72,064 KB
testcase_05 AC 154 ms
71,780 KB
testcase_06 AC 166 ms
72,700 KB
testcase_07 AC 166 ms
71,548 KB
testcase_08 AC 164 ms
71,856 KB
testcase_09 AC 158 ms
72,216 KB
testcase_10 AC 166 ms
71,844 KB
testcase_11 AC 165 ms
71,852 KB
testcase_12 AC 166 ms
72,168 KB
testcase_13 AC 167 ms
72,388 KB
testcase_14 AC 161 ms
71,676 KB
testcase_15 AC 162 ms
72,012 KB
testcase_16 AC 164 ms
71,888 KB
testcase_17 AC 161 ms
72,032 KB
testcase_18 AC 166 ms
71,676 KB
testcase_19 AC 168 ms
72,200 KB
testcase_20 AC 167 ms
71,920 KB
testcase_21 AC 164 ms
74,256 KB
testcase_22 AC 162 ms
71,952 KB
testcase_23 AC 166 ms
72,168 KB
testcase_24 AC 163 ms
71,648 KB
testcase_25 AC 164 ms
72,160 KB
testcase_26 AC 165 ms
72,208 KB
testcase_27 AC 167 ms
71,872 KB
testcase_28 AC 168 ms
71,544 KB
testcase_29 AC 168 ms
72,076 KB
testcase_30 AC 169 ms
72,500 KB
testcase_31 AC 167 ms
71,500 KB
testcase_32 AC 166 ms
72,284 KB
testcase_33 WA -
testcase_34 AC 158 ms
72,368 KB
testcase_35 AC 167 ms
72,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package puzzle.yukicoder.lengthofcandle;

import java.util.Scanner;

public class Lengthofcandle {

    public static void main(String[] args) {
        int min = 10;
        int max = 1000000000;
        int current = 100;
        Scanner cin = new Scanner(System.in);
        for (int i = 0; i < 100; i++) {
            /* 単純に2分探索したい。しかし、長さが100以下の場合、途中で燃え尽きてしまうため、探索の開始は100とする */
            System.out.println("? " + (current - i));
            System.out.flush();
            String result = cin.nextLine();
            if (result.equals("0")) {
                System.out.println("! " + current);
                System.out.flush();
                System.exit(0);
            } else if (result.equals("1")) {
                min = current;
            } else {
                max = current;
            }
            current = (min + max) / 2;
        }
    }

}
0