結果

問題 No.246 質問と回答
ユーザー lunnear
提出日時 2018-11-13 16:42:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 54,896 KB
実行使用メモリ 25,568 KB
平均クエリ数 44.90
最終ジャッジ日時 2024-07-16 16:25:07
合計ジャッジ時間 4,137 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#define MIN 1
#define	MAX	1000000000

int Center(int lower, int higher)
{
	higher += higher % 2;
	higher -= lower;
	higher /= 2;

	return lower + higher;
}

int main()
{
	int min = MIN;
	int max = MAX;

	int in;

	for(int i = 0; i < 100; i++)
	{
		int c = Center(min, max);
		std::cout << "? " << c << std::endl;
		std::cout << std::flush;

		std::cin >> in;

		(in == 1)? min = c : max = c - 1;

		if (min == max)
			break;
	}

	std::cout << "! " << min << std::endl;

	return 0;
}
0