結果

問題 No.246 質問と回答
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-04 16:32:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 3,661 ms
コンパイル使用メモリ 73,080 KB
実行使用メモリ 72,660 KB
平均クエリ数 30.97
最終ジャッジ日時 2023-09-23 20:31:52
合計ジャッジ時間 9,708 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 197 ms
72,504 KB
testcase_01 AC 185 ms
71,960 KB
testcase_02 AC 185 ms
72,380 KB
testcase_03 AC 189 ms
72,300 KB
testcase_04 AC 184 ms
72,516 KB
testcase_05 AC 186 ms
72,360 KB
testcase_06 AC 185 ms
72,296 KB
testcase_07 AC 188 ms
72,224 KB
testcase_08 AC 187 ms
72,100 KB
testcase_09 AC 185 ms
72,264 KB
testcase_10 AC 183 ms
72,240 KB
testcase_11 AC 187 ms
72,048 KB
testcase_12 AC 181 ms
72,412 KB
testcase_13 AC 181 ms
70,088 KB
testcase_14 AC 184 ms
72,256 KB
testcase_15 AC 185 ms
72,176 KB
testcase_16 AC 190 ms
71,884 KB
testcase_17 AC 188 ms
71,788 KB
testcase_18 AC 182 ms
72,216 KB
testcase_19 AC 183 ms
72,028 KB
testcase_20 AC 186 ms
72,072 KB
testcase_21 AC 187 ms
72,044 KB
testcase_22 AC 187 ms
71,932 KB
testcase_23 AC 185 ms
72,472 KB
testcase_24 AC 189 ms
72,660 KB
testcase_25 AC 186 ms
71,860 KB
testcase_26 AC 188 ms
69,624 KB
testcase_27 AC 190 ms
72,344 KB
testcase_28 AC 189 ms
69,588 KB
testcase_29 AC 191 ms
72,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int l = 1;
    int r = (int)Math.pow(10, 9) + 1;
    int ans = 0;
    while(l < r) {
      int med = (l + r) / 2;
      System.out.println("?" + " " + med);
      System.out.flush();
      int ret = sc.nextInt();
      if(ret == 1) {
        ans = med;
        l = med + 1;
      } else {
        r = med;
      }
    }
    System.out.println("!" + " " + ans);
    System.out.flush();
  }
}
0