結果

問題 No.246 質問と回答
コンテスト
ユーザー RIGIH
提出日時 2017-07-19 13:45:41
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 781 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 594 ms
コンパイル使用メモリ 88,632 KB
実行使用メモリ 28,964 KB
平均クエリ数 31.43
最終ジャッジ日時 2026-03-31 09:30:35
合計ジャッジ時間 3,279 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define mass 1000000007
using namespace std;

int main(){
	int y1=1000000000;
	int sa;
	int y=500000000;
	int res;
	rep(i,100){
		cout<<"? "<<y<<endl;
		cin>>res;
		sa=max(y1-y,y-y1)/2;
		if(sa<=1) break;
		y1=y;
		if(res){
			y=sa+y;
		}else{
			y=y-sa;
		}
	}
	//cout<<"この段階での "<<"res="<<res<<" y="<<y<<endl;
	//int t;
	//cin>>t;
	if(res){
		while(res){
			y++;
			cout<<"? "<<y<<endl;
			cin>>res;
		}
		y--;
	}else{
		while(res==0){
			y--;
			cout<<"? "<<y<<endl;
			cin>>res;
		}
	}
	cout<<"! "<<y<<endl;




	
	return 0;
	

}
	
0