結果

問題 No.253 ロウソクの長さ
ユーザー goodbatongoodbaton
提出日時 2015-07-24 22:49:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,140 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 71,500 KB
実行使用メモリ 24,348 KB
平均クエリ数 35.17
最終ジャッジ日時 2023-09-23 04:57:01
合計ジャッジ時間 5,208 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,964 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 27 ms
24,204 KB
testcase_07 AC 27 ms
23,448 KB
testcase_08 AC 27 ms
23,928 KB
testcase_09 WA -
testcase_10 AC 27 ms
23,424 KB
testcase_11 AC 27 ms
23,460 KB
testcase_12 AC 27 ms
23,976 KB
testcase_13 AC 27 ms
23,844 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 27 ms
23,856 KB
testcase_18 AC 27 ms
23,460 KB
testcase_19 WA -
testcase_20 AC 26 ms
23,292 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 26 ms
23,328 KB
testcase_24 WA -
testcase_25 AC 27 ms
23,640 KB
testcase_26 AC 28 ms
23,316 KB
testcase_27 AC 27 ms
23,436 KB
testcase_28 AC 28 ms
23,316 KB
testcase_29 AC 28 ms
24,216 KB
testcase_30 AC 28 ms
23,568 KB
testcase_31 AC 28 ms
23,652 KB
testcase_32 AC 27 ms
24,204 KB
testcase_33 AC 27 ms
23,928 KB
testcase_34 WA -
testcase_35 AC 27 ms
23,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

void ans(int Y){
    cout << "! " << Y << endl;
    return;
}

int main(){
    int res;
    
    int l=10,r=1000000000,mid;
    
    if(ask(99)==-1){
        
        for(int i=0;;i++){
            if(ask(0)==0){
                ans(i);
                return 0;
            }
        }
        
    }
    
    for(int i=1;;i++){
        
        if(l==r){
            ans(l);
            return 0;
        }
        
        mid = (l+r)/2;
        
        int q = ask(mid-i);
        
        if(q==1){
            l = mid+1;
        }else if(q==-1){
            r = mid;
        }else if(q==0){
            ans(mid);
            return 0;
        }
        
    }
    
    return 0;
}
0