Codeforces 1. Guess the Number Solultion
Solution in C++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int l=1,r=1000000;
while(l!=r)
{
int mid=(l+r+1)/2;
printf("%d\n",mid);
fflush(stdout);
char ch[5];
scanf("%s",&ch);
if(strcmp(ch,"<")==0)
{
r=mid-1;
}
else
{
l=mid;
}
}
printf("! %d\n", l);
fflush(stdout);
}
No comments