結果
| 問題 | No.253 ロウソクの長さ | 
| コンテスト | |
| ユーザー |  Bantako | 
| 提出日時 | 2018-06-01 00:18:05 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 2,000 ms | 
| コード長 | 731 bytes | 
| コンパイル時間 | 1,904 ms | 
| コンパイル使用メモリ | 167,328 KB | 
| 実行使用メモリ | 25,476 KB | 
| 平均クエリ数 | 20.69 | 
| 最終ジャッジ日時 | 2024-07-17 01:44:40 | 
| 合計ジャッジ時間 | 4,094 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 36 | 
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
            
            ソースコード
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int cnt = 1,num;
    cout << "? 100" << endl;
    fflush(0);
    cin >> num;
    int ok,ng;
    if(num == 0){
        cout << "! 100" << endl;
        return 0;
    }else if(num == -1){
       ok = 100,ng = 0;
    }else{
        ok = INF,ng = 10;
    }
    while(num){
        int mid = (ok + ng) / 2;
        cout << "? " << mid << endl;
        fflush(0);
        cin >> num;
        if(num == 1)ng = mid;
        else if(num == -1)ok = mid;
        else cout << "! " << mid+cnt << endl;
        ok--;
        ng--;
        cnt++;
    }
    fflush(0);
}
            
            
            
        