結果

問題 No.253 ロウソクの長さ
ユーザー uwiuwi
提出日時 2015-07-24 22:57:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 1,375 bytes
コンパイル時間 4,502 ms
コンパイル使用メモリ 81,060 KB
実行使用メモリ 73,852 KB
平均クエリ数 35.53
最終ジャッジ日時 2023-09-23 20:59:27
合計ジャッジ時間 11,558 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
70,328 KB
testcase_01 AC 159 ms
72,064 KB
testcase_02 AC 158 ms
72,156 KB
testcase_03 AC 153 ms
69,600 KB
testcase_04 AC 160 ms
72,360 KB
testcase_05 AC 158 ms
70,636 KB
testcase_06 AC 168 ms
69,368 KB
testcase_07 AC 174 ms
71,944 KB
testcase_08 AC 153 ms
70,100 KB
testcase_09 AC 153 ms
69,036 KB
testcase_10 AC 184 ms
72,424 KB
testcase_11 AC 175 ms
70,892 KB
testcase_12 AC 169 ms
72,236 KB
testcase_13 AC 170 ms
71,952 KB
testcase_14 AC 150 ms
70,936 KB
testcase_15 AC 158 ms
71,216 KB
testcase_16 AC 160 ms
73,852 KB
testcase_17 AC 157 ms
72,048 KB
testcase_18 AC 175 ms
72,140 KB
testcase_19 AC 157 ms
70,800 KB
testcase_20 AC 172 ms
69,684 KB
testcase_21 AC 154 ms
69,868 KB
testcase_22 AC 140 ms
69,608 KB
testcase_23 AC 172 ms
71,528 KB
testcase_24 AC 157 ms
72,096 KB
testcase_25 AC 176 ms
72,392 KB
testcase_26 AC 158 ms
69,816 KB
testcase_27 AC 175 ms
71,584 KB
testcase_28 AC 176 ms
69,520 KB
testcase_29 AC 175 ms
72,388 KB
testcase_30 AC 173 ms
68,636 KB
testcase_31 AC 156 ms
69,280 KB
testcase_32 AC 174 ms
70,684 KB
testcase_33 AC 175 ms
69,900 KB
testcase_34 AC 158 ms
70,500 KB
testcase_35 AC 164 ms
71,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
		int turn = 0;
		for(long i = low;;i*=2){
			out.println("? " + i);
			out.flush();
			int res = ni();
			if(res == 0){
				low = i+turn; high = i+turn;
				out.println("! " + low);
				out.flush();
				return;
			}else if(res == 1){
				low = i+1+turn;
			}else{
				high = i+turn;
				break;
			}
			turn++;
		}
		turn++;
		while(true){
			long h = (high-turn)+(low-turn)>>>1;
			out.println("? " + h);
			out.flush();
			int res = ni();
			if(res == 0){
				low = h+turn; high = h+turn;
				out.println("! " + low);
				out.flush();
				return;
			}else if(res == 1){
				low = h+1+turn;
			}else{
				high = h+turn;
			}
			turn++;
		}
	}
	
	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