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 ...
随机推荐
- Tomcat服务器多域名配置(转载)
Tomcat服务器多域名配置 我们来讲解下如何在Tomcat服务器上进行多域名配置: 也就是一个Tomcat跑多网站,这里用真实案例举例,比如我这个云主机需要运行两个网站: pan.java1234. ...
- 设计模式之单例模式(php实现)
github地址:https://github.com/ZQCard/design_pattern 单例模式:顾名思义就就是创建单个实例的模式. 优点:保证一个类仅有一个实例,并提供一个访问它的全局访 ...
- linux的dd命令详解
一.dd命令的解释 dd:用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换. 块大小可以使用的计量表 参数注释: 1. if=文件名:输入文件名,缺省为标准输入stdin.即指定源文件.< ...
- 联想台式机启天m4350 启用intel vt-x
在vmware workstations10 64位上安装windows server 2012操作系统时,出现例如以下错误: 已将该虚拟机配置为使用 64 位客户机操作系统.可是,无法运行 64 位 ...
- [转] docker rmi命令-删除image
原文:http://www.simapple.com/341.html ---------------------------------------------------------------- ...
- Error:[$parse:lexerr]
1.错误描写叙述 2.错误原因 由错误提示可知,有关AngularJS代码不符合语法,导致报错 3.解决的方法 检查发现,title标签中的data-ng-bind属性使用方法有误 <title ...
- 从git下载一个工程
1.右键点工程区,选“Import...” 2.Import source 选Git->“Projects from Git” 3.三个选择项中选最后一项CloneURI 4.弹出对话框,URI ...
- 使用终端shell命令批量改动一个文件下的全部文件的读写权限
之前对openfire安装的目录就遇到过这个问题,今天再次遇到.须要改动一个目录以下的全部子目录以及文件的三个权限:本用户读写.管理员读写.全部人读写,三个都要需改为wr 步骤例如以下:比如我要改动/ ...
- mongoDB - 插入数据
db.use.js /** * 使用前:先安装node环境.express.mongodb. * * 1.1 安装Node * 1.2 npm i -D express mongodb &&a ...
- Vue-router(vue2.0)用法示例
一.新建3个组件 1./src/components/post.vue <template> <div> hello world! this is POST! </div ...