結果

問題 No.246 質問と回答
ユーザー Mcpu3
提出日時 2018-09-18 00:00:52
言語 Java
(openjdk 23)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 76,480 KB
実行使用メモリ 71,048 KB
平均クエリ数 31.37
最終ジャッジ日時 2024-07-16 20:18:40
合計ジャッジ時間 9,625 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int c=1000000000,l=0,n,s=0,t;
        while(true){
            n=(c-l)/2+l;
            if(n==s)++n;
            s=n;
            System.out.println("? "+n);
            System.out.flush();
            t=sc.nextInt();
            if(t>0)l=n;
            else c=n-1;
            if(c==l){
                System.out.println("! "+c);
                System.out.flush();
                break;
            }
        }
        sc.close();
    }
}
0