結果

問題 No.246 質問と回答
ユーザー atkrymatkrym
提出日時 2016-10-23 17:18:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 2,437 ms
コンパイル使用メモリ 73,708 KB
実行使用メモリ 72,580 KB
平均クエリ数 31.00
最終ジャッジ日時 2023-09-23 20:18:44
合計ジャッジ時間 10,111 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
72,044 KB
testcase_01 AC 186 ms
72,068 KB
testcase_02 AC 188 ms
71,916 KB
testcase_03 AC 192 ms
72,060 KB
testcase_04 AC 187 ms
72,548 KB
testcase_05 AC 189 ms
72,076 KB
testcase_06 AC 188 ms
71,668 KB
testcase_07 AC 185 ms
72,392 KB
testcase_08 AC 186 ms
72,184 KB
testcase_09 AC 188 ms
71,848 KB
testcase_10 AC 188 ms
71,992 KB
testcase_11 AC 188 ms
71,924 KB
testcase_12 AC 187 ms
70,280 KB
testcase_13 AC 183 ms
72,032 KB
testcase_14 AC 188 ms
72,056 KB
testcase_15 AC 188 ms
72,132 KB
testcase_16 AC 183 ms
71,596 KB
testcase_17 AC 183 ms
72,036 KB
testcase_18 AC 184 ms
72,496 KB
testcase_19 AC 182 ms
71,732 KB
testcase_20 AC 175 ms
72,580 KB
testcase_21 AC 182 ms
72,496 KB
testcase_22 AC 183 ms
71,788 KB
testcase_23 AC 181 ms
72,176 KB
testcase_24 AC 184 ms
72,072 KB
testcase_25 AC 186 ms
72,084 KB
testcase_26 AC 184 ms
70,664 KB
testcase_27 AC 182 ms
72,156 KB
testcase_28 AC 187 ms
71,968 KB
testcase_29 AC 188 ms
72,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.text.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int ans = 500000000;
        int s = 1;
        int e = 1000000000;
        while (true) {
            System.out.println("? " + ans);
            System.out.flush();
            int ret = sc.nextInt();
            if (ret == 1) {
                s = ans;
            } else {
                e = ans-1;
            }

            ans = (s+e)/2+1;
            
            if (s == e) {
                System.out.println("! " + s);
                break;
            }
        }
    }
}
0