// Forward declaration of guess API.
// @param num, your guess
// @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
int guess(int num);
class Solution {
public:
int guessNumber(int n) {
int start=1;
int ed=n;
int t=1;
int mid;
while(start<ed)
{
mid=start+(ed-start)/2;
// cout <<start<<" "<<ed<<" "<< mid<<" "<<t<<endl;
t=guess(mid);
if(t==0) return mid;
if(mid==start) mid++;
if(t==-1)
ed=mid;
else if(t== 1)
start=mid;
}
// cout<<guess(7)<<endl;
return start;
}
};