結果
| 問題 | 
                            No.253 ロウソクの長さ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-08-01 16:17:49 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,194 bytes | 
| コンパイル時間 | 1,350 ms | 
| コンパイル使用メモリ | 158,640 KB | 
| 実行使用メモリ | 40,528 KB | 
| 平均クエリ数 | 1.03 | 
| 最終ジャッジ日時 | 2024-07-16 05:24:48 | 
| 合計ジャッジ時間 | 5,241 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 1 TLE * 1 -- * 34 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    int max_num, min_num;
    max_num = 1000000000;
    min_num = 10;
    int cnt = 0;
    int ans;
    while ((max_num - min_num) > 1) {
        if ((cnt % 10) == 0) {
            cout << "? 10" << endl;
            cin >> ans;
            if (ans != 1) {
                cnt++;
                if (ans == -1) {
                    while (true) {
                        cout << "? 0" << endl;
                        cin >> ans;
                        if (ans == 0) {
                            break;
                        }
                        cnt++;
                    }
                }
                min_num = 0;
                break;
            }
        }
        int num = (max_num + min_num) / 2;
        cout << "? " << num << endl;
        cin >> ans;
        if(ans == 0){
            min_num = num;
            break;
        }
        if(ans == 1){
            min_num = num + 1;
        }else{
            max_num = num;
        }
        max_num--;
        min_num--;
        min_num = (min_num == 0) ? 0 : min_num - 1;
        cnt++;
    }
    cout << "! " << min_num + cnt << endl;
    return 0;
}