結果

問題 No.246 質問と回答
ユーザー shimashimau67
提出日時 2015-08-01 14:09:15
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 898 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 76,304 KB
実行使用メモリ 58,588 KB
平均クエリ数 45.30
最終ジャッジ日時 2024-07-16 07:17:26
合計ジャッジ時間 10,536 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main(String[] args) {
		int max = 1000000000;
        int b = max / 2;
        int ask = max / 2;

        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 100; i++)
        {
            System.out.println("? " + ask);
            b /= 2;
            if (sc.nextInt() == 1)
            {
                ask += b;
            }
            else
            {
                ask -= b;
            }

            if (b == 0)
            {
                ask -= 13;
                while (true)
                {
                    System.out.println("? " + ask);
                    if (sc.nextInt() == 1) ask++;
                    else
                    {
                    	System.out.println("! " + (ask - 1));
                        break;
                    }
                }
            }
        }
	}
}
0