Gym 100792C Colder-Hotter (三分)
题意:系统有一个点对,让你去猜,每次你猜一个,如果这个数和系统里的那个点距离比上一个你猜的近,那么返回1,否则返回0,第一次猜一定返回0,在不超过500次的情况下,猜出正确答案。
析:是一个简单的三分,横纵坐标可以分开来考虑,每次两次三分,然后看那个点更偏向哪边即可,注意这个题,有一个坑,那就是你输出的点不能超过1e9,即使是在运算过程中也不行,也就是说上界必须是 1e9,其他的都不对,我就写了1e9+1,WA到死。。。。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#include <list>
#include <assert.h>
#include <bitset>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a, b, sizeof a)
#define sz size()
#define pu push_up
#define pd push_down
#define cl clear()
#define FOR(x,n) for(int i = (x); i < (n); ++i)
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
#define pii pair<int, int>
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e18;
const double inf = 1e20;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 18260 + 100;
const LL mod = 1000000007;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c) {
return r > 0 && r <= n && c > 0 && c <= m;
} int main(){
int ansx = 0, ansy = 1e9;
int cnt = 0, x1, x2;
int idx = 0;
while(ansx < ansy){
int m1 = ansx + (ansy - ansx) / 3;
int m2 = ansy - (ansy - ansx) / 3;
cout << 0 << " " << m1 << endl << endl;
cout.flush();
cin >> x1; cout << 0 << " " << m2 << endl << endl;
cout.flush();
cin >> x2;
if(x2 == 1) ansx = m1 + 1;
else ansy = m2 - 1;
cnt += 2;
if(cnt > 500) assert(0);
}
int ansxx = ansx;
ansx = 0, ansy = 1e9;
idx = 0;
while(ansx < ansy){
int m1 = ansx + (ansy - ansx) / 3;
int m2 = ansy - (ansy - ansx) / 3;
cout << m1 << " " << ansxx << endl << endl;
cout.flush();
cin >> x1; cout << m2 << " " << ansxx << endl << endl;
cout.flush();
cin >> x2;
if(x2 == 1) ansx = m1 + 1;
else ansy = m2 - 1;
cnt += 2;
if(cnt > 500) assert(0);
}
cout << "A " << ansx << " " << ansxx << endl;
return 0;
}
Gym 100792C Colder-Hotter (三分)的更多相关文章
- Gym - 100792C Colder-Hotter(三分交互)
Colder-Hotter Statements This is an interactive problem. Egor and Petr are playing a game called «Co ...
- Gym 101246J Buoys(三分查找)
http://codeforces.com/gym/101246/problem/J 题意: 给定x轴上的n个点的坐标,按顺序从左到右给出,现在要使得每个点的间距相同,可以移动每个点的坐标,但是不能改 ...
- POJ 2540 Hotter Colder --半平面交
题意: 一个(0,0)到(10,10)的矩形,目标点不定,从(0,0)开始走,如果走到新一点是"Hotter",那么意思是离目标点近了,如果是"Colder“,那么就是远 ...
- poj 2540 Hotter Colder 切割多边形
/* poj 2540 Hotter Colder 切割多边形 用两点的中垂线切割多边形,根据冷热来判断要哪一半 然后输出面积 */ #include <stdio.h> #include ...
- POJ 2540 Hotter Colder(半平面交)
Description The children's game Hotter Colder is played as follows. Player A leaves the room while p ...
- 【凸包】【三分】Gym - 101309D - Dome of Circus
容易发现,圆锥体积和点的具体x.y坐标无关,只与其到z轴的距离sqrt(x*x+y*y)有关. 于是将这些三维的点都投射到二维的xOy平面的第二象限(sqrt(x*x+y*y),z),求个上凸壳,然后 ...
- Gym 2009-2010 ACM ICPC Southwestern European Regional Programming Contest (SWERC 2009) A. Trick or Treat (三分)
题意:在二维坐标轴上给你一堆点,在x轴上找一个点,使得该点到其他点的最大距离最小. 题解:随便找几个点画个图,不难发现,答案具有凹凸性,有极小值,所以我们直接三分来找即可. 代码: int n; lo ...
- POJ 2540 Hotter Colder
http://poj.org/problem?id=2540 题意:给你每次行走的路径,而且告诉你每次离一个点光源是远了还是近了,要求每次光源可能存在的位置的面积. 思路:如果出现"same ...
- codeforces GYM 100971F 公式题或者三分
F. Two Points time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
随机推荐
- 基于Tomcat 的WEB Project存在的安全漏洞总结
1 检查工具:Acunetix Web Vulnerability Scanner V9破解版 2 检查漏洞说明结果显示: 2.1 HTML Form Without CSRF Protection ...
- angularJS的ng-repeat-start
使用angularJS的同学对ng-repeat都不会陌生,他是用来进行数据循环的,一般用于数组或者对象.但是今天我们用到了一个ng-repeat-start. ng-repeat-start,与ng ...
- AHK的OnMessage
OnMessage(0x404, "AHK_NOTIFYICON") AHK_NOTIFYICON(wParam, lParam) { if (lParam = 0x202) ; ...
- [Java.web]JSTL 使用
<%@ page import="cn.itcast.domain.Person"%> <%@ page language="java" im ...
- [C#]读文件
代码段来自 支付宝接口代码示例 /// <summary> /// 从文件读取公钥转公钥字符串 /// </summary> /// <param name=" ...
- dd命令的conv=fsync,oflag=sync/dsync
conv的参数有 1.sync Pad every input block to size of 'ibs' with trailing zero bytes. When used with 'blo ...
- solr之高级查询--联表 join查询
例如有两个业务表:文章表,评论表 . 场景: 一个文章可以由多个人评论. 创建两个core,一个core叫article,一个叫comment.article实例的schema.xml文件中定义几个简 ...
- 自己动手实现RPC服务调用框架
转自:http://www.cnblogs.com/rjzheng/p/8971629.html#3977269 担心后面忘了,先转了,后面借鉴实现一下RPC -------------------- ...
- Django学习---Form组件认证
Form组件认证 能够帮助我们做用户认证. 以前写我们自己写用户认证的时候,我们自己写HTML的form表单,点击提交,数据就被发送到后台,后台进行验证.在验证过程中我们就需要自己去写正则表达式去匹配 ...
- windows下使用 ApiGen 生成php项目的开发文档
之前使用 PHPDocument 生成过开发文档,但是界面看着不爽,遂尝试了 ApiGen 生成,不得不说界面看着舒服多了,下面说说安装和使用的方法. ApiGen官网: http://www.api ...