题干:

Tea is good.

Tea is life.

Tea is everything.

The balance of tea is a journey of pursuing balance of the universe.

Alice knows that.

Alice wants to teach you the art of pouring tea.

Alice has a pot of tea.

The exact volume of tea is not important.

The exact volume of tea is at least LL.

The exact volume of tea is at most RR.

Alice put two empty cups between you and her.

Alice wants the two cups filled by almost equal volume of tea.

Yours cannot be 11 unit more than hers.

Hers cannot be 11 unit more than yours.

Alice wants you to pour the tea.

Alice wants you to pour until the pot is almost empty.

Alice wants no more than 11 unit volume of tea remaining in the pot.

You cannot read the residue volume of tea remaining in the pot.

You can only know the tea status in the pot, empty or not.

Alice does not want you to pour the tea too many times.

You better pour as few times as possible.

Input

There are multiple cases. 
For each case, there is one line of two integers LL and RR, separated by single space.

Here are some analyses about sample cases. 
For the first case, pouring 11 unit into one cup will satisfy Alice. 
For the second case, it is clearly that you cannot only pour once to reach the desired balance, but she can achieve it by pouring twice. 
First you pour 1.51.5 units into one cup, then you attempt to pour another 1.51.5 units into the other cup. 
Since the lower bound is 22, at least 0.50.5 unit remains in the pot after the first pouring. 
If the initial volume is in range [2,3][2,3], the second cup will have volume in range [0.5,1.5][0.5,1.5] which is balanced with 1.51.5 unit in the first cup, and at most 11 unit remain after these two attempts.

About 10001000 test cases, and 0≤L≤R≤10160≤L≤R≤1016.

Output

For each case, there should be a single integer in a single line, the least number of pouring attempts.

Sample Input

2 2
2 4

Sample Output

1
2

题目大意:

有一壶水, 体积在 L 和 R 之间, 有两个杯子, 你要把水倒到两个杯子里面, 使得杯子水体积几乎相同(体积的差值小于等于1), 并且使得壶里剩下水体积不大于1. 你无法测量壶里剩下水的体积, 问最小需要倒水的次数。

解题报告:

就是个找规律题,没啥意思,为了保险就特判了一堆。

第一次倒给第一个杯子L/2+0.5是比较合适的,第二次倒给第二个杯子L/2+0.5+1,再给第一个杯子倒2L,继续这样直到壶只剩小于等于1L。

最后的公式就是 (R - L) / 2  + 1。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;int main()
{ll l,r;while(~scanf("%lld%lld",&l,&r)) {if(r <= 1) puts("0");else if(r <= 2) puts("1");else if(l == 0) {printf("%lld\n",(r-1)/2 + 1);}else if(l == r || l+1 == r|| l+2==r) puts("2");else {printf("%lld\n",1+(r-l)/2);}}return 0 ;
}

【HDU - 5881】Tea(思维,找规律)相关推荐

  1. HDU 5963 朋友(找规律)

    朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submiss ...

  2. HDU 6229 Wandering Robots 找规律+离散化

    题目链接:Wandering Robots 题解:先讲一下规律,对于每一个格子它可以从多少个地方来有一个值(可以从自己到自己),然后答案就是统计合法格子上的数与所有格子的数的比值 比如说样例的3 0格 ...

  3. CodeForces - 1245C Constanze's Machine(思维+找规律)

    题目链接:点击查看 题目大意:给出一个字符串s,该字符串是由一台坏掉的打字机生成的,坏掉的打字机会将m打成nn,将w打成uu,问现在给出字符串s,其原本的字符串有多少种可能性 题目分析:因为m会变成n ...

  4. HDU - 6267 (概论/找规律/递推)

    VJ地址 题目大意: 有n个节点 从0-(n-1),连边的规律为 即i点的父亲只能是比i小的数,而且是随机的,现在随机选择应该一个节点作为根,求这子树的和的期望是多少. 思路:可以知道总共有(n-1) ...

  5. Grid game CodeForces - 1104C 放格子|思维|找规律

    题意:4*4的格子中输入0放 2*1的图案输入1放1*2的图案 当摆满一行或一列后此行列图案清空 就想毛熊方块一样 分析:开始感觉很唬人 要搜索还是要dp啥的 后来发现原来2*1就放左下 1*2就放左 ...

  6. 第十五届北京师范大学程序设计竞赛决赛(网络同步赛) B lca水 D 思维,找规律...

    第十五届北京师范大学程序设计竞赛决赛(网络同步赛) B. Borrow Classroom 题意:一棵树,点 1为根,一个人从点 b到 点 c再到点 1,第二个人从点 a出发,问第二个人能否截住第一个 ...

  7. HDU 5914 Triangle 数学找规律

    Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...

  8. C - Sweets Eating 前缀和 + 思维找规律

    传送门 思路:1.找出最优策略 2.优化代码 最主要的是如何优化代码,我们发现m是一个周期,在m周期类的元素不会受到影响,一旦到达一个周期,那么此时的数值就要整体移一位,这个可以用前缀和来实现. 设d ...

  9. HDU ACM 1046 Gridland 找规律

    分析:给出一个矩阵.问最短从一个点经过全部点以此回到起点的长度是多少.绘图非常好理解.先画3*4.3*3.4*4的点阵图案.试着在上面用最短路走一走,能够发现当矩形点阵的长宽都是奇数时,最短路中必然有 ...

  10. hdu 4506(快速幂+找规律)

    小明系列故事--师兄帮帮忙 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Pr ...

最新文章

  1. Adobe奇葩续费机制被网友狂喷:一不留神就扣2500,按月付费还随时取订?长点心吧...
  2. 如何网络推广教你如何网站排名“更上一层楼”?
  3. 骚出天际!一个程序员女装照片的开源项目
  4. 《C++ Primer》14.1节练习
  5. 拖拽功能-jquery
  6. go设计模式之单例模式
  7. jenkins手把手教你从入门到放弃01-jenkins简介
  8. Compilation failed: internal java compiler error
  9. 7.剑指Offer --- 两个面试案例
  10. 海康SDK方式对接摄像头
  11. 【详解】BiLSTM+CRF模型
  12. blastn、blastp、blastx、tblastn和tblastx的区别与用法
  13. 《下学梯航》(全文)
  14. vue——微信二维码显示vue-qr/qrcodejs2
  15. 美团实习生电面之谈(成功拿到offer)
  16. 记:判断三个点是否在一条直线上
  17. 阿里云-密钥管理系统密钥导入功能
  18. UVA - 10041 Vito's Family (中位数)
  19. 分享一组超喜欢的粉色樱花高清壁纸~
  20. 使用计算机求解问题首先要,基于计算机的问题求解,首先要完成的是( )

热门文章

  1. WCF系列(1)—— CustomBehavior 入门
  2. 关于DateTime和String转换的容易犯得错误
  3. ★ Flex を使って Scalable Vector Graphics とビットマップを描画する
  4. [剑指offer]面试题第[2]题[JAVA][替换空格][函数][字符串]
  5. linux日志服务器配置在哪个文件,Linux中日志的基本配置(syslog)
  6. tableau地图城市数据_举个栗子!Tableau 技巧(156):在地图分析中创建缓冲区
  7. 福师2018计算机应用基础,中石油华东《计算机应用基础》2018年秋学期在线作业100分答案满分...
  8. 区分大小屏幕_VESA持续推动DisplayHDR认证计划,你的屏幕属于何种等级吗?
  9. 获取apk安装包sha1的值
  10. arduino 水位传感器_云南可信赖的威卡压力传感器哪里有