結果

問題 No.253 ロウソクの長さ
ユーザー fiord
提出日時 2015-07-25 00:32:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 1,306 ms
コンパイル使用メモリ 159,012 KB
実行使用メモリ 25,604 KB
平均クエリ数 78.19
最終ジャッジ日時 2024-07-16 05:06:30
合計ジャッジ時間 7,163 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int ask(int y){
	cout<<"? "<<y<<endl;
	int ans;
	cin>>ans;
	return ans;
}
int main(){
	int ple=100;
	int left=1e9,right=10;
	int cnt=0;
	for(;cnt<10;cnt++){
		int ans=ask((ple+right)/2);
		if(ans==0){
			printf("!%d\n",(ple+right)/2+cnt);
			return 0;
		}
		else if(ans==1)	right=(ple+right)/2;
		else 	ple=(ple+right)/2;
	}
	for(;cnt<100;cnt++){
		int ans=ask((left+right)/2);
		if(ans==0){
			printf("!%d\n",(left+right)/2+cnt);
			return 0;
		}
		else if(ans==1)	right=(left+right)/2;
		else 	left=(left+right)/2;
	}
}
0