III USP Freshmen ContestH. MaratonIME gets candies
这题挺有意思的,刚开始不会这交互题,模仿着做了一题就会了,蛮简单 的
这题我用2分,结果wa了,想了一下发现,1到1e9二分50次完全不够用啊,那就转换一下思维,先求出在10^n~10^(n+1)的n
然后进行二分,这样居然a了。。。
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=,inf=; int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll l=,r=;
string str;
for(int i=;i<=;i++)
{
cout<<"Q "<<l<<endl;
cout.flush();
cin>>str;
if(str=="=")return ;
if(str==">")l*=;
else if(str=="<")
{
r=l;
l/=;
break;
}
}
for(int i=;i<=;i++)
{
ll m=(l+r)/;
cout<<"Q "<<m<<endl;
cout.flush();
cin>>str;
if(str==">")l=m;
else if(str=="<")r=m;
else return ;
}
return ;
}
III USP Freshmen ContestH. MaratonIME gets candies的更多相关文章
- Gym - 101375H MaratonIME gets candies 交互题
交互题介绍:https://loj.ac/problem/6 题意:输出Q X ,读入><= 来猜数,小于50步猜出就算过样例 题解:根本不需要每次输出要打cout.flush()... ...
- 用Kotlin开发Android应用(III):扩展函数和默认值
这是关于Kotlin的第三篇. 原文标题:Kotlin for Android (III): Extension functions and default values 原文链接:http://an ...
- LeetCode Single Number I / II / III
[1]LeetCode 136 Single Number 题意:奇数个数,其中除了一个数只出现一次外,其他数都是成对出现,比如1,2,2,3,3...,求出该单个数. 解法:容易想到异或的性质,两个 ...
- SPOJ GSS3 Can you answer these queries III[线段树]
SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...
- 【Codeforces717F】Heroes of Making Magic III 线段树 + 找规律
F. Heroes of Making Magic III time limit per test:3 seconds memory limit per test:256 megabytes inpu ...
- LeetCode——Best Time to Buy and Sell Stock III (股票买卖时机问题3)
问题: Say you have an array for which the ith element is the price of a given stock on day i. Design a ...
- 【POJ2886】Who Gets the Most Candies?-线段树+反素数
Time Limit: 5000MS Memory Limit: 131072K Case Time Limit: 2000MS Description N children are sitting ...
- 1. Two Sum I & II & III
1. Given an array of integers, return indices of the two numbers such that they add up to a specific ...
- 【LeetCode】Single Number I & II & III
Single Number I : Given an array of integers, every element appears twice except for one. Find that ...
随机推荐
- [EF]vs15+ef6+mysql这个问题,你遇到过么?
写在前面 因为最近用mysql比较多,所以想了解下ef+mysql的内容,发现ef连接mysql数据库,还有那么一段路折腾.折腾到最后,发疯了. 步骤 这里采用db first的方式来使用ef. 通过 ...
- 沈阳网络赛I-Lattice's basics in digital electronics【模拟】
42.93% 1000ms 131072K LATTICE is learning Digital Electronic Technology. He is talented, so he under ...
- RGBA HSB opengl光照模型
RGBA HSB HSV颜色模型对应于画家的配色的方法.画家用改变色浓和色深的方法来从某种纯色获得不同色调的颜色.其做法是:在一种纯色中加入白色以改变色浓,加入黑色以改变色深,同时加入不同比例的白 ...
- Python开发【项目】:博客后台
概述 通过自己写的博客后台代码.思路,来与武sir的代码进行一个差异化的比较,记录之间的差距,改善以后写代码的思路 博客后台这个项目,对之前Django学习的各个知识点都有涉及到,非常重要 用户登录验 ...
- 'ascii' codec can't decode byte 0xc4 in position 27: ordinal not in range(128)
This error happens when I try to run d:\linux\linuxkernel\android\内核\blog\BlogBackup(v1.1)source\htm ...
- Redux 入门教程
Redux 入门教程(三):React-Redux 的用法(53@2016.09.21) Redux 入门教程(二):中间件与异步操作(32@2016.09.20) Redux 入门教程(一):基本用 ...
- centos7 安装python3.6 及模块安装演示
目录: 下载python3.6 安装python3.6的依赖 编译安装 更改链接 更改yum脚本的python依赖 修改gnome-weaktool配置文件 修改urlgrabber配置文件 1.下载 ...
- onvif协议client与server对接
happytimesoft有完整的c语言开发的onvif client和server,一共1000$,真便宜,haha. http://www.happytimesoft.com/products/m ...
- C# 多线程编程第二步——线程同步与线程安全
上一篇博客学习了如何简单的使用多线程.其实普通的多线程确实很简单,但是一个安全的高效的多线程却不那么简单.所以很多时候不正确的使用多线程反倒会影响程序的性能. 下面先看一个例子 : class Pro ...
- uva11020 set
有n个人,每个人有两个属性x,y.如果对于一个人P(x,y) 不存在另外一个人(x',y') 使得x'<x,y'<=y 或者 x'<=x,y'<y 我们说p是有优势的,每次给出 ...