Tea HDU - 5881
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.
InputThere 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.OutputFor 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,R]之间,
所以说一次倒2L是最快的,先要使一个杯子里面的茶比另外一个杯子里面的茶多1L
然后一次倒2L
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int main() {
long long L,R;
while(scanf("%lld%lld",&L,&R)!=EOF){
long long sum;
if (R<=) sum=;
else if (R<=) sum=;
else {
if (L==) sum=(R+)/;
else {
sum=(R-L)/+;
if (sum<) sum=;
}
}
printf("%lld\n",sum);
}
return ;
}
Tea HDU - 5881的更多相关文章
- hdu 5881 Tea (2016 acm 青岛网络赛)
原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5881 Tea Time Limit: 3000/1000 MS (Java/Others) Me ...
- HDU 5881 Tea
Tea Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- HDU 5881 Tea -2016 ICPC 青岛赛区网络赛
题目链接 题意:有一壶水, 体积在 L和 R之间, 有两个杯子, 你要把水倒到两个杯子里面, 使得杯子水体积几乎相同(体积的差值小于等于1), 并且使得壶里剩下水体积不大于1. 你无法测量壶里剩下水的 ...
- HDU 5881 Tea (模拟)
题意:有一壶水, 体积在 LLL 和 RRR 之间, 有两个杯子, 你要把水倒到两个杯子里面, 使得杯子水体积几乎相同(体积的差值小于等于1), 并且使得壶里剩下水体积不大于1. 你无法测量壶里剩下水 ...
- 【2016 ACM/ICPC Asia Regional Qingdao Online】
[ HDU 5878 ] I Count Two Three 考虑极端,1e9就是2的30次方,3的17次方,5的12次方,7的10次方. 而且,不超过1e9的乘积不过5000多个,于是预处理出来,然 ...
- hdu Hat's Tea
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1288 去买茶,需要正好的钱才行,另外花的钱的个数最多 其实是一个简单的贪心问题,小的多取一点,多的少 ...
- HDU 6667 Roundgod and Milk Tea (思维)
2019 杭电多校 8 1011 题目链接:HDU 6667 比赛链接:2019 Multi-University Training Contest 8 Problem Description Rou ...
- HDU 6667 Roundgod and Milk Tea
hdu题面 Time limit 6000 ms Memory limit 131072 kB OS Windows Source 2019 Multi-University Training Con ...
- hdu 1288 Hat's Tea
这个要慢慢理解…… ;}
随机推荐
- 在C#中“?”有三种用法
在C#中“?”有三种用法. 1.可空类型修饰符(?):引用类型可以使用空引用表示一个不存在的值,而值类型通常不能表示为空,例如:string str=null;是正确的.int i=null:编译器将 ...
- memcached安装与使用详解
一.memcache的简介 memcache是高速,分布式的内存缓存服务器 php的缓存方式一般可以使用memcache技术和redis技术,其中各有优劣,因不同的情况而选择较为适合的缓存技术,其中m ...
- [Python Study Notes]CS架构远程访问获取信息--SERVER端
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- java单例模式学习笔记
最近一直在学习多线程,在学习过程中遇到了关于单例模式的多线程安全问题,内容如下: 一:首先什么是单例模式 单例模式具有的三要点: 一个类只能有一个实例: 必须是由它自己创建的这个实例: 它必须自行向外 ...
- checkbox/input文本框与文字对齐
3种方法都能实现checkbox文本框或radio文本框与文字对齐: <meta charset="utf-8"> <input style="vert ...
- hplus--H+ V2.3 (中文版)
一个高大上的后台模板 演示地址 http://www.zi-han.net/theme/hplus/?v=4.1 下载地址 http://download.csdn.net/detail/u01197 ...
- 【收藏】8段JQuery处理表单的代码片段,很实用
1 只接受数字输入 $("#uAge").keydown(function(event) { // 允许退格和删除键 if ( event.keyCode == 46 || eve ...
- Oracle创建表时Storage参数具体含义
本文通过图表和实例的阐述在Oracle数据库创建新表时Storage的参数具体含义. 可用于:表空间.回滚段.表.索引.分区.快照.快照日志 参数名称 缺省值 最小值 最大值 说明 INITIAL 5 ...
- 二叉排序树、平衡二叉树、B树&B+树、红黑树的设计动机、缺陷与应用场景
之前面试时曾被问到"如果实现操作系统的线程调度应该采用什么数据结构?",因为我看过ucore的源码,知道ucore是采用斜堆的方式实现的,可以做到O(n)的插入.O(1)的查找.我 ...
- Python网络编程(2)-粘包现象及socketserver模块实现TCP并发
1. 基于Tcp的远程调用命令实现 很多人应该都使用过Xshell工具,这是一个远程连接工具,通过上面的知识,就可以模拟出Xshell远程连接服务器并调用命令的功能. Tcp服务端代码如下: impo ...