Gym

交互题介绍:https://loj.ac/problem/6

题意:输出Q X ,读入><= 来猜数,小于50步猜出就算过样例

题解:根本不需要每次输出要打cout.flush()。。。

ac:

#include<iostream>
#include<string>
using namespace std;
int main() {
    int l = 1, r = 1e9;
    while (l <= r) {
        int mid = (l + r) / 2;
        cout << 'Q' << ' ' << mid << endl;
        
        string c;
        cin >> c;
        //if (c == "=") {  break; }
        if (c == "<") r = mid - 1;
        else l = mid + 1;
    }
    cout << 'Q' << ' ' << l << endl;
    
}

//看到一个Bangladesh University of Business & Technology的老哥的代码,给跪了(借用一下)

  

成功的路并不拥挤,因为大部分人都在颓(笑)
原文地址:https://www.cnblogs.com/SuuT/p/8511481.html