結果

問題 No.2252 Find Zero
ユーザー ks2mks2m
提出日時 2023-03-24 21:26:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 4,609 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 73,048 KB
平均クエリ数 78.17
最終ジャッジ日時 2023-10-18 20:43:00
合計ジャッジ時間 7,759 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
72,976 KB
testcase_01 AC 239 ms
73,032 KB
testcase_02 AC 149 ms
72,660 KB
testcase_03 AC 200 ms
73,048 KB
testcase_04 AC 157 ms
72,920 KB
testcase_05 AC 151 ms
72,660 KB
testcase_06 AC 152 ms
72,656 KB
testcase_07 AC 152 ms
72,832 KB
testcase_08 AC 189 ms
72,984 KB
testcase_09 AC 208 ms
72,808 KB
testcase_10 AC 151 ms
72,828 KB
testcase_11 AC 148 ms
72,672 KB
testcase_12 AC 147 ms
72,672 KB
testcase_13 AC 146 ms
72,672 KB
testcase_14 AC 148 ms
72,652 KB
testcase_15 AC 151 ms
72,828 KB
testcase_16 AC 150 ms
72,672 KB
testcase_17 AC 150 ms
72,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int n2 = n / 2;
		for (int i = 0; i < n2; i++) {
			int x = i * 2;
			int y = x + 1;
			System.out.println("? " + x + " " + y);
			int z = Integer.parseInt(br.readLine());
			if (z == x) {
				System.out.println("! " + y);
				return;
			}
			if (z == y) {
				System.out.println("! " + x);
				return;
			}
		}
		System.out.println("! " + (n - 1));
		br.close();
	}
}
0