Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- int T;
- scanf("%d",&T);
- for(int t=1;t<=T;t++){
- int a,b;
- scanf("%d %d",&a,&b);
- a++;
- int n;
- scanf("%d",&n);
- int i = 0;
- char str[20];
- do{
- int m = (a+b)/2;
- printf("%d\n",m);
- i++;
- fflush(stdout);
- scanf("%s",str);
- if(!strcmp(str,"WRONG_ANSWER"))return -1;
- if(!strcmp(str,"TOO_SMALL")){
- a = m + 1;
- }
- else if(!strcmp(str,"TOO_BIG")){
- b = m - 1;
- }
- }while(strcmp(str,"CORRECT") && i < n);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment