题意:系统有一个点对,让你去猜,每次你猜一个,如果这个数和系统里的那个点距离比上一个你猜的近,那么返回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. 根据tomcat的日志判断web的发布路径以及服务路径

    [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.unde ...

  2. vue2.0实现一个模态弹框,内容自定义(使用slot)

    定义模态框:合理使用插槽 model.vue <!-- 模态弹窗 --> <template> <div class="self-modal" v-s ...

  3. .NET实现WebSocket服务端即时通信实例

    即时通信常用手段 1.第三方平台 谷歌.腾讯 环信等多如牛毛,其中谷歌即时通信是免费的,但免费就是免费的并不好用.其他的一些第三方一般收费的,使用要则限流(1s/限制x条消息)要么则限制用户数. 但稳 ...

  4. Oracle约束详解

    一 约束的定义 约束是强加在表上的规则或条件.确保数据库满足业务规则.保证数据的完整性.当对表进行DML或DDL操作时,如果此操作会造成表中的数据违反约束条件或规则的话,系统就会拒绝执行这个操作.约束 ...

  5. vim自定义配置之autoComplPop设置

    BundlenInstall安装autoComplPop vimConfig/plugin/autoComplPop-setting.vim "autocomplpop 设置 let g:A ...

  6. 教你使用markdown画程序流程图

    2016-01-21 10:33:15 星期四 1. 入门案例 st=>start: Start op=>operation: Your Operation sub=>subrout ...

  7. Log4j(1)--hellloworld

    创建项目: 使用的是log4j-1.2.17.jar: log4j.properties: log4j.rootLogger=DEBUG, Console ,File #Console log4j.a ...

  8. CentOS iptables防火墙的基本应用讲解

    iptables是Linux下不错的防火墙软件,本文主要给大家介绍下iptables的安装.规则增加和清除.开放指定端口.屏蔽指定ip和ip段等CentOS下iptables的基本应用. 一.ipta ...

  9. Lucene根据字段进行自定义搜索扩展

    最近需要对公司的产品搜索功能做一步改动,搜索到的结果首先按照是否有库存进行排序,然后再按照销量.由于库存量也是一个整数,如果直接按照库存量进行倒序排序的话,是不符合要求的,Lucene也没有支持我们这 ...

  10. Bootstrap的介绍和响应式媒体查询

    Bootstrap的介绍 凡是使用过Bootstrap的开发者,都不在乎做这么两件事情:复制and粘贴.哈哈~,是的使用Bootstrap非常简单,但是在复制粘贴之前,需要先对Bootstrap的用法 ...