#include #include #include #include #include #include #include //ifstream fin("1.in"); //ofstream fout("1.out"); using namespace std; bool solve(int n, int m, int x) { if(n%x == 0) return (m-2)%x == 0; if(n%x == 1) return (m-1)%x == 0; if(n%x == 2) return m%x == 0; return false; } int main() { int n, k; cin>>n>>k; //read the number of stories and eggs int dr = n; int st = 1; string response = ""; while(response != "exit") { if(st == dr){ //in case you've found the answer cout << "answer " << st << "\n"; cout.flush(); cin >> response; //the response is going to be "exit" } else { int x = (dr+st)/2; cout << "query " << x << "\n"; //can also use endl for newline cout.flush(); cin >> response; if(response == "broke") { k--; dr = x; } else st = x+1; } } return 0; }