結果

問題 No.246 質問と回答
ユーザー Mcpu3Mcpu3
提出日時 2018-09-18 00:00:52
言語 Java19
(openjdk 21)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 2,337 ms
コンパイル使用メモリ 74,536 KB
実行使用メモリ 74,308 KB
平均クエリ数 31.37
最終ジャッジ日時 2023-09-23 20:29:22
合計ジャッジ時間 10,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 186 ms
72,440 KB
testcase_01 AC 188 ms
72,180 KB
testcase_02 AC 185 ms
72,396 KB
testcase_03 AC 183 ms
72,672 KB
testcase_04 AC 184 ms
72,672 KB
testcase_05 AC 182 ms
72,480 KB
testcase_06 AC 183 ms
74,308 KB
testcase_07 AC 184 ms
72,256 KB
testcase_08 AC 185 ms
72,292 KB
testcase_09 AC 190 ms
72,728 KB
testcase_10 AC 194 ms
72,272 KB
testcase_11 AC 186 ms
72,340 KB
testcase_12 AC 186 ms
72,068 KB
testcase_13 AC 181 ms
71,660 KB
testcase_14 AC 182 ms
71,532 KB
testcase_15 AC 181 ms
71,444 KB
testcase_16 AC 182 ms
71,948 KB
testcase_17 AC 182 ms
72,516 KB
testcase_18 AC 179 ms
72,120 KB
testcase_19 AC 184 ms
70,516 KB
testcase_20 AC 184 ms
72,744 KB
testcase_21 AC 180 ms
71,992 KB
testcase_22 AC 183 ms
71,928 KB
testcase_23 AC 182 ms
72,112 KB
testcase_24 AC 184 ms
71,856 KB
testcase_25 AC 182 ms
71,940 KB
testcase_26 AC 177 ms
72,480 KB
testcase_27 AC 178 ms
72,364 KB
testcase_28 AC 185 ms
71,568 KB
testcase_29 AC 179 ms
72,364 KB
権限があれば一括ダウンロードができます

ソースコード

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