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 ...
随机推荐
- Python自动发布Image service的实现
使用Python自动发布地图服务已经在上一篇博客中讲到,使用Python创建.sd服务定义文件,实现脚本自动发布ArcGIS服务,下面是利用Python自动发布Image service的实现. -- ...
- describe neural networks as a series of computational steps via a directed graph.
https://www.microsoft.com/en-us/research/product/cognitive-toolkit/ https://github.com/microsoft/cnt ...
- kubernetes实战(四):k8s持久化安装rabbitmq集群
1.下载文件 https://github.com/dotbalo/k8s/ 2.创建namespace kubectl create namespace public-service 如果不使用pu ...
- ansible(3)
一.setup模块 ansible的setup模块主要用来收集信息,查看参数: [root@localhost ~]# ansible-doc -s setup # 查看参数,部分参数如下: filt ...
- Java-idea-PMD源文件级别潜在bug查看
一.概述 PMD(Project Manager Design)是一种开源分析Java代码错误的工具.与其他分析工具不同的是,PMD通过静态分析获知代码错误.也就是说,在不运行Java程序的情况下报告 ...
- spring boot 重定向
/** * 测试各个html文件用. * @param model * @return */ @RequestMapping("home") public String home( ...
- MapReduce的几个实现
1.倒排索引的实现 import java.io.IOException; import java.util.StringTokenizer; import org.apache.hadoop.con ...
- [翻译] Rails::Railtie
原文:http://api.rubyonrails.org/classes/Rails/Railtie.html Railtie 是 Rails 框架的核心,提供几个钩子来扩展或修改 Rails 的 ...
- VS2010/MFC编程入门之十三(对话框:属性页对话框及相关类的介绍)
前面讲了模态对话框和非模态对话框,本节开始鸡啄米讲一种特殊的对话框--属性页对话框.另外,本套教程所讲大部分对VC++各个版本均可适用或者稍作修改即可,但考虑到终究还是基于VS2010版本的,所以将& ...
- 利用ssh-copy-id复制公钥到多台服务器
http://www.cnblogs.com/panchong/p/6027138.html?utm_source=itdadao&utm_medium=referral # 连接新主机时,不 ...