結果

問題 No.253 ロウソクの長さ
ユーザー masamasa
提出日時 2016-07-13 22:35:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 65,268 KB
実行使用メモリ 24,360 KB
平均クエリ数 24.81
最終ジャッジ日時 2023-09-24 00:11:34
合計ジャッジ時間 3,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,436 KB
testcase_01 AC 20 ms
23,412 KB
testcase_02 AC 20 ms
24,324 KB
testcase_03 AC 23 ms
23,412 KB
testcase_04 AC 23 ms
23,436 KB
testcase_05 AC 22 ms
24,012 KB
testcase_06 AC 22 ms
23,412 KB
testcase_07 AC 21 ms
23,916 KB
testcase_08 AC 19 ms
24,324 KB
testcase_09 AC 20 ms
23,808 KB
testcase_10 AC 20 ms
23,652 KB
testcase_11 AC 21 ms
23,544 KB
testcase_12 AC 20 ms
24,060 KB
testcase_13 AC 22 ms
24,012 KB
testcase_14 AC 22 ms
23,424 KB
testcase_15 AC 22 ms
23,844 KB
testcase_16 AC 20 ms
23,712 KB
testcase_17 AC 20 ms
24,048 KB
testcase_18 AC 20 ms
23,448 KB
testcase_19 AC 19 ms
23,664 KB
testcase_20 AC 20 ms
23,640 KB
testcase_21 AC 24 ms
23,652 KB
testcase_22 AC 20 ms
23,556 KB
testcase_23 AC 25 ms
24,288 KB
testcase_24 AC 21 ms
23,400 KB
testcase_25 AC 19 ms
23,580 KB
testcase_26 AC 19 ms
23,424 KB
testcase_27 AC 21 ms
23,676 KB
testcase_28 AC 21 ms
24,120 KB
testcase_29 AC 21 ms
24,120 KB
testcase_30 AC 21 ms
24,048 KB
testcase_31 AC 21 ms
24,252 KB
testcase_32 AC 21 ms
24,360 KB
testcase_33 AC 20 ms
23,676 KB
testcase_34 AC 19 ms
23,424 KB
testcase_35 AC 20 ms
23,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>

using namespace std;

int n_ask = 0;

int ask(int Y){
	cout << "? " << Y << endl;
	int res;
	cin >> res;
	n_ask++;
	return res;
}

int main() {
	int ret = ask(64);

	if (ret == 0) {
		cout << "? 64" << endl;
		return 0;
	}

	int n_bit = ret == 1 ? 31 : 6;
	int ans = 1 << n_bit;
	ans--;
	for (int i = n_bit - 1; i >= 0; i--) {
		int tmp = ans - (1 << i);
		ret = ask(tmp - n_ask);
		if (ret == 0) {
			ans = tmp;
			break;
		} else if (ret < 0) {
			ans = tmp;
		}
	}
	cout << "! " << ans << endl;
}
0