結果
| 問題 | 
                            No.253 ロウソクの長さ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-08-01 16:19:35 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,298 bytes | 
| コンパイル時間 | 1,351 ms | 
| コンパイル使用メモリ | 159,300 KB | 
| 実行使用メモリ | 25,604 KB | 
| 平均クエリ数 | 30.86 | 
| 最終ジャッジ日時 | 2024-07-16 05:25:36 | 
| 合計ジャッジ時間 | 8,546 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 1 WA * 35 | 
ソースコード
//
// Created by Owner on 2015/08/01.
//
#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 >= 10) ? min_num - 1 : 10;
        cnt++;
        if (cnt >= 100) {
            break;
        }
    }
    cout << "! " << min_num + cnt << endl;
    return 0;
}