結果

問題 No.246 質問と回答
ユーザー Lay_ec
提出日時 2015-07-17 23:04:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 80,660 KB
実行使用メモリ 25,604 KB
平均クエリ数 31.30
最終ジャッジ日時 2024-07-16 19:44:12
合計ジャッジ時間 4,229 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;


int main()
{

    long long l=1,r=1000000000;
    
    while(l+1<r){
        long long m=(l+r)/2;
        //cout<<"l="<<l<<" r="<<r<<" m="<<m<<endl;
        cout<<"? "<<m<<endl;
        int res;
        cin>>res;
        
        if(res) l=m;
        else r=m-1;
    }

    cout<<"? "<<r<<endl;
	int res;
	cin>>res;
	
	if(res) cout<<"! "<<r<<endl;
	else cout<<"! "<<l<<endl;

    return 0;
}
0