結果

問題 No.246 質問と回答
ユーザー yuki2006
提出日時 2015-07-13 11:23:00
言語 Java
(openjdk 23)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 3,348 ms
コンパイル使用メモリ 76,680 KB
実行使用メモリ 58,680 KB
平均クエリ数 30.87
最終ジャッジ日時 2024-07-16 19:37:07
合計ジャッジ時間 10,692 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 response = scanner.nextInt();
            if (response == 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