結果

問題 No.246 質問と回答
ユーザー yuki2006yuki2006
提出日時 2015-07-13 11:11:02
言語 Java
(openjdk 23)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 4,327 ms
コンパイル使用メモリ 76,324 KB
実行使用メモリ 58,688 KB
平均クエリ数 30.87
最終ジャッジ日時 2024-07-16 19:36:47
合計ジャッジ時間 12,908 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yuki_Reactive {

    public Yuki_Reactive() {
        Scanner scanner = new Scanner(System.in);
        int A = 0;
        int B = (int) (1e+9) + 1;
        while (B - A > 1) {
            int c = (B + A) / 2;
            System.out.println("? " + c);
            System.out.flush();
            final int responce = scanner.nextInt();
            if (responce == 1) {
                A = c;
            } else {
                B = c;
            }
        }
        System.out.println("! " + A);
        System.out.flush();

    }

    public static void main(String[] args) {
        Yuki_Reactive hoge = new Yuki_Reactive();
    }
}
0