結果
問題 | No.253 ロウソクの長さ |
ユーザー |
|
提出日時 | 2015-07-24 22:53:56 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,334 bytes |
コンパイル時間 | 3,586 ms |
コンパイル使用メモリ | 81,760 KB |
実行使用メモリ | 74,256 KB |
平均クエリ数 | 35.53 |
最終ジャッジ日時 | 2025-02-07 08:46:17 |
合計ジャッジ時間 | 14,574 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 36 |
ソースコード
package contest;import java.io.PrintWriter;import java.util.Arrays;import java.util.Scanner;public class Q687 {static Scanner in;static PrintWriter out;static String INPUT = "";static void solve(){long low = 10, high = 1000000001;for(long i = low;;i*=2){out.println("? " + i);out.flush();int res = ni();if(res == 0){low = i; high = i;out.println("! " + (low-1));out.flush();return;}else if(res == 1){low = i+1;}else{high = i;break;}low--; high--;}low--; high--;while(true){long h = high+low>>>1;out.println("? " + h);out.flush();int res = ni();if(res == 0){low = h; high = h;out.println("! " + (low-1));out.flush();return;}else if(res == 1){low = h+1;}else{high = h;}low--; high--;}}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)); }}