这题挺有意思的,刚开始不会这交互题,模仿着做了一题就会了,蛮简单 的

这题我用2分,结果wa了,想了一下发现,1到1e9二分50次完全不够用啊,那就转换一下思维,先求出在10^n~10^(n+1)的n

然后进行二分,这样居然a了。。。

  1. #include<map>
  2. #include<set>
  3. #include<cmath>
  4. #include<queue>
  5. #include<stack>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<cassert>
  9. #include<iomanip>
  10. #include<cstdlib>
  11. #include<cstring>
  12. #include<iostream>
  13. #include<algorithm>
  14. #define pi acos(-1)
  15. #define ll long long
  16. #define mod 1000000007
  17. #define ls l,m,rt<<1
  18. #define rs m+1,r,rt<<1|1
  19. #pragma comment(linker, "/STACK:1024000000,1024000000")
  20.  
  21. using namespace std;
  22.  
  23. const double g=10.0,eps=1e-;
  24. const int N=+,maxn=,inf=;
  25.  
  26. int main()
  27. {
  28. ios::sync_with_stdio(false);
  29. cin.tie();
  30. ll l=,r=;
  31. string str;
  32. for(int i=;i<=;i++)
  33. {
  34. cout<<"Q "<<l<<endl;
  35. cout.flush();
  36. cin>>str;
  37. if(str=="=")return ;
  38. if(str==">")l*=;
  39. else if(str=="<")
  40. {
  41. r=l;
  42. l/=;
  43. break;
  44. }
  45. }
  46. for(int i=;i<=;i++)
  47. {
  48. ll m=(l+r)/;
  49. cout<<"Q "<<m<<endl;
  50. cout.flush();
  51. cin>>str;
  52. if(str==">")l=m;
  53. else if(str=="<")r=m;
  54. else return ;
  55. }
  56. return ;
  57. }

III USP Freshmen ContestH. MaratonIME gets candies的更多相关文章

  1. Gym - 101375H MaratonIME gets candies 交互题

    交互题介绍:https://loj.ac/problem/6 题意:输出Q X ,读入><= 来猜数,小于50步猜出就算过样例 题解:根本不需要每次输出要打cout.flush()... ...

  2. 用Kotlin开发Android应用(III):扩展函数和默认值

    这是关于Kotlin的第三篇. 原文标题:Kotlin for Android (III): Extension functions and default values 原文链接:http://an ...

  3. LeetCode Single Number I / II / III

    [1]LeetCode 136 Single Number 题意:奇数个数,其中除了一个数只出现一次外,其他数都是成对出现,比如1,2,2,3,3...,求出该单个数. 解法:容易想到异或的性质,两个 ...

  4. 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 ...

  5. 【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 ...

  6. 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 ...

  7. 【POJ2886】Who Gets the Most Candies?-线段树+反素数

    Time Limit: 5000MS Memory Limit: 131072K Case Time Limit: 2000MS Description N children are sitting ...

  8. 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 ...

  9. 【LeetCode】Single Number I & II & III

    Single Number I : Given an array of integers, every element appears twice except for one. Find that ...

随机推荐

  1. 修改Yii2的默认语言language为中文zh-CN的方法

    如果用的语言是en-US的话,网页加载速度很慢,因为要加载国外镜像或者链接什么的,使用zh-CN就直接加载国内链接或者CDN,速度比较快: ------------------------------ ...

  2. 拨开障目的叶,一览CMDB庐山真面目

    人们往往用"一叶障目,不见泰山"来形容一个人被局部现象所迷惑,看不到事物发展的整体脉络,从而做出一些不是十分正确的决策.小编觉得对于运维何尝不是这样呢. 大多数企业资产配置维护的现 ...

  3. KVM中断虚拟化浅析

    2017-08-24 今天咱们聊聊KVM中断虚拟化,虚拟机的中断源大致有两种方式,来自于用户空间qemu和来自于KVM内部. 中断虚拟化起始关键在于对中断控制器的虚拟化,中断控制器目前主要有APIC, ...

  4. yum whatprovides 查找哪个包可以提供缺失的文件

    yum whatprovides 查找哪个包可以提供缺失的文件

  5. 商铺项目(使用DES加密配置信息)

    package com.ouyan.o2o.util; import java.security.Key; import java.security.SecureRandom; import java ...

  6. 跟我学Makefile(二)

    命令出错: 每当命令运行完后, make 会检测每个命令的返回码,如果命令返回成功,那么 make 会执行下一条命令. 如果一个规则中的某个命令出错了(命令退出码非零),那么 make 就会终止执行当 ...

  7. 如何用 testNG 生成测试报告

    原文地址https://testerhome.com/topics/3473 总结一下testNG生成报告的三种方式,基本都是我直接转载的,没有补充就不说了,有补充的我会加以说明的(这里直说生成报告, ...

  8. 菜单条 Menu Bar Action

    //.h /***Action**/ QAction * act_openImage; QAction * act_openVideo; QAction * act_openAudio; /***Me ...

  9. 小论“Boolean参数作为入参”的函数

    <Clean Code>一书中对于如何写好函数有着很动人的描写,其中对于函数参数的建议有如下两点: 函数参数的数量应该尽可能少 给一个一元函数传入bool类型的参数很"罪恶&qu ...

  10. PHP文件锁 解决并发问题

    使用多线程或是多进程时. 难免会遇到并发问题. 处理简单的并发可以使用这个办法来解决 flock($fp = fopen($lock, 'w+'), LOCK_EX | LOCK_NB)   or e ...