結果

問題 No.246 質問と回答
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-16 21:50:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 3,059 ms
コンパイル使用メモリ 72,980 KB
実行使用メモリ 74,392 KB
平均クエリ数 30.90
最終ジャッジ日時 2023-09-23 20:16:40
合計ジャッジ時間 10,245 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
71,708 KB
testcase_01 AC 174 ms
71,996 KB
testcase_02 AC 172 ms
72,188 KB
testcase_03 AC 176 ms
72,524 KB
testcase_04 AC 173 ms
72,516 KB
testcase_05 AC 173 ms
71,532 KB
testcase_06 AC 178 ms
71,872 KB
testcase_07 AC 177 ms
72,248 KB
testcase_08 AC 176 ms
72,612 KB
testcase_09 AC 177 ms
72,056 KB
testcase_10 AC 172 ms
69,940 KB
testcase_11 AC 177 ms
72,032 KB
testcase_12 AC 172 ms
72,404 KB
testcase_13 AC 175 ms
71,912 KB
testcase_14 AC 172 ms
72,552 KB
testcase_15 AC 173 ms
72,840 KB
testcase_16 AC 179 ms
72,312 KB
testcase_17 AC 175 ms
72,448 KB
testcase_18 AC 176 ms
72,304 KB
testcase_19 AC 176 ms
72,732 KB
testcase_20 AC 177 ms
72,772 KB
testcase_21 AC 183 ms
72,292 KB
testcase_22 AC 177 ms
72,192 KB
testcase_23 AC 175 ms
72,096 KB
testcase_24 AC 178 ms
72,024 KB
testcase_25 AC 176 ms
72,496 KB
testcase_26 AC 172 ms
72,520 KB
testcase_27 AC 178 ms
74,392 KB
testcase_28 AC 179 ms
72,764 KB
testcase_29 AC 178 ms
71,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise90{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int head = 1;
    int tail = 1000000000;
    int center = 0;
    while(true){
      center = (tail - head) / 2 + head;
      if(tail - head < 2){
        break;
      }
      System.out.println("? " + center);
      System.out.flush();

      int answer = sc.nextInt();
      
      if(answer == 0){
        tail = center;
      }else{
        head = center;
      }
    }
    System.out.println("! " + center);
  }
}
0