結果

問題 No.253 ロウソクの長さ
ユーザー 沙耶花
提出日時 2022-03-22 22:29:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 647 bytes
コンパイル時間 3,870 ms
コンパイル使用メモリ 250,168 KB
最終ジャッジ日時 2025-01-28 11:01:17
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001
int cnt = 0;

void answer(int n){
	cout<<"? "<<n<<endl;
	exit(0);
}

//is greater n?
bool query(int n){
	cout<<"? "<<n<<endl;
	int r;
	cin>>r;
	if(r==0){
		answer(n+cnt);
	}
	cnt++;
	if(r==1)return true;
	return false;
}

int main(){
	
	bool f = query(50);
	if(f){
		int ok = 50,ng = 1000000005;
		while(ng-ok>1){
			int mid = (ok+ng)/2;
			if(query(mid-cnt))ok = mid;
			else ng = mid;
		}
	}
	else{
		while(true)query(0);
	}
	
	return 0;
}
0