結果
問題 | No.246 質問と回答 |
ユーザー |
|
提出日時 | 2015-07-19 16:06:09 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 217 ms / 2,000 ms |
コード長 | 965 bytes |
コンパイル時間 | 3,861 ms |
コンパイル使用メモリ | 82,696 KB |
実行使用メモリ | 71,268 KB |
平均クエリ数 | 30.90 |
最終ジャッジ日時 | 2024-07-16 19:49:03 |
合計ジャッジ時間 | 12,274 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
package q5xx; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class Q551 { static Scanner in; static PrintWriter out; static String INPUT = ""; static void solve() { int low = 1, high = 1000000000+1; while(high - low > 1){ int h = high+low>>>1; if(go(h)){ low = h; }else{ high = h; } } out.println("! " + low); } static boolean go(int h) { out.println("? " + h); out.flush(); return ni() == 1; } public static void main(String[] args) throws Exception { in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT); out = new PrintWriter(System.out); solve(); out.flush(); } static int ni() { return Integer.parseInt(in.next()); } static long nl() { return Long.parseLong(in.next()); } static double nd() { return Double.parseDouble(in.next()); } static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); } }