题意:系统有一个点对,让你去猜,每次你猜一个,如果这个数和系统里的那个点距离比上一个你猜的近,那么返回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 (三分)的更多相关文章

  1. Gym - 100792C Colder-Hotter(三分交互)

    Colder-Hotter Statements This is an interactive problem. Egor and Petr are playing a game called «Co ...

  2. Gym 101246J Buoys(三分查找)

    http://codeforces.com/gym/101246/problem/J 题意: 给定x轴上的n个点的坐标,按顺序从左到右给出,现在要使得每个点的间距相同,可以移动每个点的坐标,但是不能改 ...

  3. POJ 2540 Hotter Colder --半平面交

    题意: 一个(0,0)到(10,10)的矩形,目标点不定,从(0,0)开始走,如果走到新一点是"Hotter",那么意思是离目标点近了,如果是"Colder“,那么就是远 ...

  4. poj 2540 Hotter Colder 切割多边形

    /* poj 2540 Hotter Colder 切割多边形 用两点的中垂线切割多边形,根据冷热来判断要哪一半 然后输出面积 */ #include <stdio.h> #include ...

  5. POJ 2540 Hotter Colder(半平面交)

    Description The children's game Hotter Colder is played as follows. Player A leaves the room while p ...

  6. 【凸包】【三分】Gym - 101309D - Dome of Circus

    容易发现,圆锥体积和点的具体x.y坐标无关,只与其到z轴的距离sqrt(x*x+y*y)有关. 于是将这些三维的点都投射到二维的xOy平面的第二象限(sqrt(x*x+y*y),z),求个上凸壳,然后 ...

  7. Gym 2009-2010 ACM ICPC Southwestern European Regional Programming Contest (SWERC 2009) A. Trick or Treat (三分)

    题意:在二维坐标轴上给你一堆点,在x轴上找一个点,使得该点到其他点的最大距离最小. 题解:随便找几个点画个图,不难发现,答案具有凹凸性,有极小值,所以我们直接三分来找即可. 代码: int n; lo ...

  8. POJ 2540 Hotter Colder

    http://poj.org/problem?id=2540 题意:给你每次行走的路径,而且告诉你每次离一个点光源是远了还是近了,要求每次光源可能存在的位置的面积. 思路:如果出现"same ...

  9. codeforces GYM 100971F 公式题或者三分

    F. Two Points time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

随机推荐

  1. Servlet技术基础

    由于Servlet部分涉及较多的类,要想尽快掌握Servlet基础,必须熟悉使用这些类之间的关系以及其常用的方法. 主要讲解部分包括: 1)通过实现Servelt接口来编写Servlet 2)熟悉Se ...

  2. HiveSQL正则表达式的应用[转]

    最近工作中数据处理方面用到很多不是特别容易处理的数据,用正则表达式的话会让语句显得特别精简,也可以用各种字符串截取函数嵌套处理(必须要有一定规律),总结一下经常用到的几个. 1.正则的通配符简介    ...

  3. 为eclipse安装python、shell开发环境和SVN插件

    http://www.crazyant.net/1185.html 为eclipse安装python.shell开发环境和SVN插件 2013/08/27 by Crazyant 暂无评论 eclip ...

  4. IP分片(IP Fragment)

    为什么要分片 不同的链路类型能够支持的最大传输单元值(MTU: Maxitum Transmission Unit)主要是由相关RFC文档规定的,常见的以太网链路的MTU值为1500,如果需要转发的I ...

  5. python 简明教程

    第一个源程序 #!/usr/bin/python# Filename : helloworld.pyprint 'Hello world' 执行: $ python helloworld.py 或者  ...

  6. mac php apache mysql 集成环境 的软件

    http://xclient.info/s/mamp-pro.html?t=4e60e3c234937f46b33e6b15eeafeb5ee326afa4 MAMP Pro 5.1 集成web服务器 ...

  7. selenium笔记2017

    1,from time import sleep(先引入关键词) sleep(5)       (就可以使用这个命令了) 可以停止页面5秒 1-1. 等待页面元素出现的时间(即没出现时,等待元素出现) ...

  8. http://www.bootcss.com/p/font-awesome/

    集成 将Font Awesome 集成到 Bootstrap 非常容易,还可以被单独使用. 最简单的 Bootstrap + Font Awesome 集成方式 使用这种方式将 Font Awesom ...

  9. 本地通过源码方式启动solr

      首先,下载solr5.5.0源码,http://apache.fayea.com/lucene/solr/5.5.0/solr-5.5.0-src.tgz   解压完成后,分为几个目录,然而sol ...

  10. alibaba fastjson的使用总结和心得

      最初接触alibaba fastjson是由于其性能上的优势,对比原来采用codehause.jackson的解析,在hadoop平台上的手动转换对象有着将近1/3的性能提升,但随着开发应用越来越 ...