結果

問題 No.253 ロウソクの長さ
コンテスト
ユーザー goodbaton
提出日時 2015-07-24 22:37:04
言語 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
結果
WA  
実行時間 -
コード長 943 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 678 ms
コンパイル使用メモリ 95,108 KB
実行使用メモリ 28,976 KB
平均クエリ数 49.47
最終ジャッジ日時 2026-03-30 19:15:21
合計ジャッジ時間 5,634 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000003
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100

int ask(int Y){
    cout << "? " << Y << endl;
    int res;
    cin >> res;
    return res;
}

int main(){
    int res;
    
    int l=10,r=1000000000,mid;
    
    for(int i=0;i<50;i++){
        
        mid = (l+r)/2;
        
        int q = ask(mid-i*2);
        
        if(q==1){
            l=mid+1;
        }else if(q==-1){
            r = mid-1;
        }else{
            cout << "! " << mid << endl;
            return 0;
        }
        
        if(ask(0)==0){
            cout << "! " << i*2+1 << endl;
            return 0;
        }
        
    }
    
    return 0;
}
0