結果

問題 No.246 質問と回答
ユーザー kohaku_kohaku
提出日時 2016-12-02 21:39:25
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 591 bytes
コンパイル時間 2,385 ms
コンパイル使用メモリ 76,508 KB
実行使用メモリ 73,048 KB
平均クエリ数 72.80
最終ジャッジ日時 2024-07-16 11:25:36
合計ジャッジ時間 10,306 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 RE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int min=1;
        int max=(int)Math.pow(10,9);
        
        while(true){
            int mid=(max+min)/2;
            System.out.println("? "+mid);
            System.out.flush();
            int x = sc.nextInt();
            if(x==1){
                min=mid;
            }else{
                max=mid-1;
            }
            if(max==min){
                System.out.println("! "+max);
                break;
            }
        }
    }
}
0