結果

問題 No.253 ロウソクの長さ
ユーザー sugim48sugim48
提出日時 2015-07-24 22:34:40
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 814 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 25,580 KB
平均クエリ数 24.44
最終ジャッジ日時 2024-07-16 20:48:26
合計ジャッジ時間 3,597 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> i_i;
int MOD = 1000000007;

int main() {
	int lb = 0, ub = 101;
	int t = 0;
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		cout << "? " << mid - t << endl;
		int x; cin >> x;
		if (x == 0) {
			cout << "! " << mid << endl;
			return 0;
		}
		if (x == 1) lb = mid;
		else ub = mid;
		t++;
	}
	lb = 0, ub = 1000000001;
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		cout << "? " << mid - t << endl;
		int x; cin >> x;
		if (x == 0) {
			cout << "! " << mid << endl;
			return 0;
		}
		if (x == 1) lb = mid;
		else ub = mid;
		t++;
	}
}
0