結果

問題 No.246 質問と回答
ユーザー uwiuwi
提出日時 2015-07-19 16:06:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 3,812 ms
コンパイル使用メモリ 76,184 KB
実行使用メモリ 56,252 KB
平均クエリ数 30.90
最終ジャッジ日時 2023-09-23 20:01:10
合計ジャッジ時間 11,414 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 192 ms
55,664 KB
testcase_01 AC 174 ms
54,008 KB
testcase_02 AC 188 ms
55,228 KB
testcase_03 AC 181 ms
55,140 KB
testcase_04 AC 191 ms
55,480 KB
testcase_05 AC 181 ms
55,728 KB
testcase_06 AC 186 ms
55,664 KB
testcase_07 AC 187 ms
55,320 KB
testcase_08 AC 180 ms
55,480 KB
testcase_09 AC 165 ms
54,576 KB
testcase_10 AC 184 ms
55,940 KB
testcase_11 AC 182 ms
55,708 KB
testcase_12 AC 186 ms
55,648 KB
testcase_13 AC 186 ms
55,564 KB
testcase_14 AC 185 ms
55,896 KB
testcase_15 AC 181 ms
55,700 KB
testcase_16 AC 183 ms
55,440 KB
testcase_17 AC 184 ms
55,552 KB
testcase_18 AC 186 ms
56,252 KB
testcase_19 AC 182 ms
55,576 KB
testcase_20 AC 182 ms
55,444 KB
testcase_21 AC 185 ms
55,524 KB
testcase_22 AC 184 ms
55,972 KB
testcase_23 AC 186 ms
55,408 KB
testcase_24 AC 186 ms
55,384 KB
testcase_25 AC 185 ms
55,596 KB
testcase_26 AC 184 ms
55,420 KB
testcase_27 AC 185 ms
55,480 KB
testcase_28 AC 175 ms
55,804 KB
testcase_29 AC 183 ms
55,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)); }
}
0