Colder-Hotter
题目链接:
http://codeforces.com/gym/100792/problem/C
解题思路:
先对x进行二分,再对y进行二分。
AC代码:
#include <bits/stdc++.h>
using namespace std;
int main(){
int x,y = 0,op;
int l = 0,r = 1e9;
printf("%d %d\n",l,y);
cout.flush();
scanf("%d",&op);
while(l < r){
printf("%d %d\n",r,y);
cout.flush();
scanf("%d",&op);
int mid = (l+r)>>1;
if(op == 0)
r = mid;
else
l = mid+1;
printf("%d %d\n",l,y);
cout.flush();
scanf("%d",&op);
}
x = l;
l = 0, r = 1e9;
printf("%d %d\n",x,l);
cout.flush();
scanf("%d",&op);
while(l < r){
printf("%d %d\n",x,r);
cout.flush();
scanf("%d",&op);
int mid = (l+r)>>1;
if(op == 0)
r = mid;
else
l = mid+1;
printf("%d %d\n",x,l);
cout.flush();
scanf("%d",&op);
}
y = l;
printf("A %d %d\n",x,y);
cout.flush();
return 0;
}