結果
| 問題 | No.253 ロウソクの長さ | 
| コンテスト | |
| ユーザー |  chocorusk | 
| 提出日時 | 2018-10-11 16:27:51 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 2,000 ms | 
| コード長 | 877 bytes | 
| コンパイル時間 | 837 ms | 
| コンパイル使用メモリ | 94,264 KB | 
| 実行使用メモリ | 25,220 KB | 
| 平均クエリ数 | 27.25 | 
| 最終ジャッジ日時 | 2024-07-17 01:57:52 | 
| 合計ジャッジ時間 | 3,842 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 36 | 
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
	int x1=10, x2=1e3;
	int ct=0;
	for(int i=0; i<10; i++){
		int x=(x1+x2)/2;
		printf("? %d\n", x-ct); fflush(stdout);
		ct++;
		int t;
		cin>>t;
		if(t==0){
			printf("! %d\n", x); fflush(stdout);
			return 0;
		}else if(t==1){
			x1=x+1;
		}else{
			x2=x-1;
		}
	}
	x1=1e3, x2=1e9;
	while(1){
		int x=(x1+x2)/2;
		printf("? %d\n", x-ct); fflush(stdout);
		ct++;
		int t;
		cin>>t;
		if(t==0){
			printf("! %d\n", x); fflush(stdout);
			return 0;
		}else if(t==1){
			x1=x+1;
		}else{
			x2=x-1;
		}
	}
	return 0;
}
            
            
            
        