hdu 5881 Tea (2016 acm 青岛网络赛)
原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5881
Tea
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 451 Accepted Submission(s): 124
Problem
Description
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 L.
The exact volume of tea is at most R.
Alice put two empty cups between you and her.
Alice wants the two cups filled by almost equal volume of tea.
Yours cannot be 1
unit more than hers.
Hers cannot be 1
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 1
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 L
and R,
separated by single space.
Here are some analyses about sample cases.
For the first case, pouring 1 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.5
units into one cup, then you attempt to pour another 1.5
units into the other cup.
Since the lower bound is 2,
at least 0.5
unit remains in the pot after the first pouring.
If the initial volume is in range [2,3],
the second cup will have volume in range [0.5,1.5]
which is balanced with 1.5
unit in the first cup, and at most 1
unit remain after these two attempts.
About 1000
test cases, and 0≤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
Source
2016 ACM/ICPC Asia Regional Qingdao Online
#include<stdio.h>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cstdio>
#include <cmath> #define LL long long using namespace std;
LL l,r; LL solve(LL l,LL r)
{
if(r<=) return ;
if(r<=) return ;
if(l==r||l==r-) return ;
if(l<=) l=;
return (r-l)/+;
} int main()
{
while(scanf("%lld%lld",&l,&r)!=EOF)
{
cout<<solve(l, r)<<endl;
}
return ;
}
hdu 5881 Tea (2016 acm 青岛网络赛)的更多相关文章
- HDU 5881 Tea -2016 ICPC 青岛赛区网络赛
题目链接 题意:有一壶水, 体积在 L和 R之间, 有两个杯子, 你要把水倒到两个杯子里面, 使得杯子水体积几乎相同(体积的差值小于等于1), 并且使得壶里剩下水体积不大于1. 你无法测量壶里剩下水的 ...
- 2016 年青岛网络赛---Tea
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5881 Problem Description Tea is good. Tea is life. Te ...
- 2016 年青岛网络赛---Family View(AC自动机)
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5880 Problem Description Steam is a digital distribut ...
- 2016 年青岛网络赛---Sort(k叉哈夫曼)
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5884 Problem Description Recently, Bob has just learn ...
- HDU 5901 Count primes (2016 acm 沈阳网络赛)
原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5901 题意:输入n,输出n以内质数个数 模板题,模板我看不懂,只是存代码用. 官方题解链接:https ...
- HDU 5884 Sort(2016年青岛网络赛 G 二分+贪心+小优化)
好题 题意:给你n<=100000个数,每个数范围[0,1000],然后给你一个最大的代价T,每次最多合并k个数成为一个数,代价为k个数的总和.问最后合成1个数的总代价不大于T的最小k 题解:我 ...
- HDU 6215 2017Brute Force Sorting 青岛网络赛 队列加链表模拟
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6215 题意:给你长度为n的数组,定义已经排列过的串为:相邻两项a[i],a[i+1],满足a[i]&l ...
- 2016 acm香港网络赛 C题. Classrooms(贪心)
原题网址:https://open.kattis.com/problems/classrooms Classrooms The new semester is about to begin, and ...
- 2016 acm香港网络赛 B题. Boxes
原题网址:https://open.kattis.com/problems/boxes Boxes There are N boxes, indexed by a number from 1 to N ...
随机推荐
- 程序编译时书写Makefile注意事项一例
在进行程序编译时,可能需要指定一些库的库的路径.头文件的路径,分别使用的参数选项是-L和-I,需要注意的是: 需要确保-L和-I后边的内容不为空,否则会出现意想不到的错误,而这种错误比较难以发现,引起 ...
- UVA 1665 Islands
题意:输入一个n*m矩阵,每一个格子都有一个正整数,再输入T个整数ti,对于每一个ti,输出大于ti的正整数组成多少个四连快 思路:正着做的话事实上相当于删除连通块,而假设反着做的话就相当于变成添加连 ...
- vsftp 服务配置篇
在CentOS或者RedHat Linux上有自带的ftp软件叫做vsftpd (very serure ftp) 搭建vsftpd 服务 yum 安装需要用两个包:vsftpd 和 db4-util ...
- django自定义过滤器及模板标签
创建一个模板库 不管是写自定义标签还是过滤器,第一件要做的事是创建模板库(Django能够导入的基本结构). 创建一个模板库分两步走: 第一,决定模板库应该放在哪个Django应用下. 如果你通过 m ...
- Oracle 11g Flashback_transaction_query的undo_sql为空解决办法
近日测试的时候发现 flashback_transaction_query中 undo_sql 为空,经查证这个问题是 Oracle 11g 默认把 supplemental logging 禁用了导 ...
- HDU 2767 Proving Equivalences (强联通)
pid=2767">http://acm.hdu.edu.cn/showproblem.php?pid=2767 Proving Equivalences Time Limit: 40 ...
- 联想Y430P CentOS 7.3 无线网络的配置
# uname -a # 查看内核/操作系统/CPU信息的Linux系统信息命令 [root@www ~]# uname -a Linux www SMP Tue Nov :: UTC x86_64 ...
- EffectiveJava(20)使用子类型化优化标签类
标签类:其中有许多样板代码,包括枚举声明,标签域和条件语句 如果要给它添加风格,除了有权限修改源码之外,你还得给每个条件语句都添加一个条件,否则就会在运行时失败 标签类过于冗长,容易出错,并且效率低下 ...
- UI自动化测试篇 :ReportNG替代TestNG自带html版测试报告初探
转载http://www.cnblogs.com/chengtch/p/6071322.html “1.1.4版本的ReportNG是最后一个版本,之后不再做维护.作为一个简单的测试报告插件,它是创造 ...
- redis学习笔记——入门
基本安装和用法:http://www.tuicool.com/articles/QzMRNb Redis如何通过本机客户端访问远程服务器段:http://blog.sina.com.cn/s/blog ...