結果

問題 No.253 ロウソクの長さ
ユーザー cled0328
提出日時 2024-10-12 12:34:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 336 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 191,636 KB
最終ジャッジ日時 2025-02-24 17:28:11
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool ask(int y){
	cout<<"? "<<y<<endl;
	int res;
	cin>>res;
	return res>=0;
}

int main(){
	int ct=1;
	int l,r;
	if(ask(138)){
		l=138,r=1e9+1;
	}else{
		l=10,r=138;
	}
	while(r-l>1){
		int mid=(l+r)/2;
		if(ask(mid-ct)){
			l=mid;
		}else{
			r=mid;
		}
		ct++;
	}
	cout<<"! "<<l<<endl;
}
0