結果

問題 No.246 質問と回答
ユーザー 37zigen37zigen
提出日時 2016-03-22 18:07:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 74,056 KB
実行使用メモリ 57,520 KB
平均クエリ数 31.53
最終ジャッジ日時 2023-09-23 20:14:43
合計ジャッジ時間 10,406 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 196 ms
55,596 KB
testcase_01 AC 191 ms
55,780 KB
testcase_02 AC 188 ms
55,712 KB
testcase_03 AC 192 ms
55,948 KB
testcase_04 AC 192 ms
55,084 KB
testcase_05 AC 190 ms
55,848 KB
testcase_06 AC 190 ms
55,460 KB
testcase_07 AC 186 ms
55,700 KB
testcase_08 AC 185 ms
55,496 KB
testcase_09 AC 188 ms
55,720 KB
testcase_10 AC 185 ms
55,788 KB
testcase_11 AC 186 ms
55,792 KB
testcase_12 AC 185 ms
55,604 KB
testcase_13 AC 186 ms
55,836 KB
testcase_14 AC 197 ms
57,520 KB
testcase_15 AC 187 ms
55,492 KB
testcase_16 AC 193 ms
55,756 KB
testcase_17 AC 187 ms
55,520 KB
testcase_18 AC 187 ms
56,136 KB
testcase_19 AC 187 ms
55,460 KB
testcase_20 AC 187 ms
55,420 KB
testcase_21 AC 188 ms
55,496 KB
testcase_22 AC 187 ms
55,708 KB
testcase_23 AC 185 ms
55,276 KB
testcase_24 AC 186 ms
55,612 KB
testcase_25 AC 186 ms
54,924 KB
testcase_26 AC 186 ms
55,652 KB
testcase_27 AC 186 ms
54,768 KB
testcase_28 AC 187 ms
55,492 KB
testcase_29 AC 185 ms
55,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder246;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int upper=(int)Math.pow(10, 9);
		int low=0;
		
		while(upper!=low){
			int mid=(int)(upper+low)/2;
			System.out.println("? "+mid);
			int a=sc.nextInt();
			if(a==1){
				low=mid;
				if(upper==low||upper==low+1){
					System.out.println("! "+low);
					sc.close();
					return;
				}
			}else{
				upper=mid;
				if(upper==low){
					System.out.println("! "+upper);
					sc.close();
					return;
				}
			}
		}
		
	}
}
0