結果

問題 No.253 ロウソクの長さ
ユーザー mamekin
提出日時 2016-01-30 00:19:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,163 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 91,252 KB
実行使用メモリ 25,220 KB
平均クエリ数 33.33
最終ジャッジ日時 2024-07-16 22:53:21
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int res;
    cout << "? 100" << endl;
    cin >> res;

    int ans;
    if(res != 1){
        for(int i=10; ; ++i){
            cout << "? 9" << endl;
            cin >> res;
            if(res == 0){
                ans = i;
                break;
            }
        }
    }
    else{
        int a = 101;
        int b = 1000000000;
        for(int i=1; ; ++i){
            int mid = (a + b) / 2;
            cout << "? " << (mid - i) << endl;
            cin >> res;
            if(res < 0){
                b = mid - 1;
            }
            else if(res > 0){
                a = mid + 1;
            }
            else{
                ans = mid;
                break;
            }
        }
    }

    cout << "! " << ans << endl;
    return 0;
}
0