結果

問題 No.253 ロウソクの長さ
ユーザー nCk_cvnCk_cv
提出日時 2015-08-01 15:31:09
言語 Java19
(openjdk 21)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 4,250 ms
コンパイル使用メモリ 75,756 KB
実行使用メモリ 72,784 KB
平均クエリ数 26.92
最終ジャッジ日時 2023-09-23 21:14:33
合計ジャッジ時間 11,623 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 174 ms
72,120 KB
testcase_01 AC 157 ms
72,292 KB
testcase_02 AC 172 ms
72,312 KB
testcase_03 AC 153 ms
71,664 KB
testcase_04 AC 158 ms
71,868 KB
testcase_05 AC 158 ms
71,852 KB
testcase_06 AC 174 ms
72,784 KB
testcase_07 AC 169 ms
72,136 KB
testcase_08 AC 174 ms
72,468 KB
testcase_09 AC 152 ms
72,272 KB
testcase_10 AC 168 ms
72,060 KB
testcase_11 AC 167 ms
72,016 KB
testcase_12 AC 166 ms
72,184 KB
testcase_13 AC 182 ms
72,356 KB
testcase_14 AC 157 ms
72,048 KB
testcase_15 AC 172 ms
72,364 KB
testcase_16 AC 166 ms
72,312 KB
testcase_17 AC 175 ms
71,880 KB
testcase_18 AC 173 ms
72,140 KB
testcase_19 AC 160 ms
72,664 KB
testcase_20 AC 173 ms
71,768 KB
testcase_21 AC 162 ms
72,064 KB
testcase_22 AC 157 ms
72,156 KB
testcase_23 AC 177 ms
72,540 KB
testcase_24 AC 171 ms
72,404 KB
testcase_25 AC 171 ms
72,172 KB
testcase_26 AC 173 ms
71,816 KB
testcase_27 AC 175 ms
72,188 KB
testcase_28 AC 173 ms
72,120 KB
testcase_29 AC 173 ms
72,200 KB
testcase_30 AC 174 ms
71,888 KB
testcase_31 AC 171 ms
72,424 KB
testcase_32 AC 170 ms
71,596 KB
testcase_33 AC 169 ms
72,408 KB
testcase_34 AC 161 ms
71,988 KB
testcase_35 AC 174 ms
72,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = 0;
		int e = 64;
		int count = 0;
		boolean al = false;
		while(s <= e) {
			System.out.println("? " + (s + e)/2);
			count++;
			int in = sc.nextInt();
			if(in == -1){
				e = (s + e)/2-1;
				s--;
			}
			if(in == 1) {
				s = (s + e)/2;
				e--;
			}
			if(in == 0) {
				al = true;
				System.out.println("! " + ((s + e)/2 + count-1));
				break;
			}
		}
		
		
		if(!al) {
			s = 0;
			e = 1000000001;
			while(true) {
				System.out.println("? " + (s + e)/2);
				count++;
				int in = sc.nextInt();
				if(in == -1){
					e = (s + e)/2-1;
					s--;
				}
				if(in == 1) {
					s = (s + e)/2;
					e--;
				}
				if(in == 0) {
					al = true;
					System.out.println("! " + ((s + e)/2 + count-1));
					break;
				}
			}
		}
	}
}
0