2016 年青岛网络赛---Tea
题目链接
http://acm.hdu.edu.cn/showproblem.php?pid=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 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.
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.
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <string.h>
using namespace std; int main()
{
long long L,R;
while(scanf("%lld%lld",&L,&R)!=EOF)
{
if(L==R)
{
if(R<=) puts("");
else if(R==) puts("");
else puts("");
continue;
}
if(L==)
{
if(R==) puts("");
else if(R==) puts("");
else printf("%lld\n",(R+)/);
}
else
{
if(L==&&R==) puts("");
else{
if(L+>=R-) puts("");
else printf("%lld\n",(R-L+)/);
}
}
}
return ;
}
2016 年青岛网络赛---Tea的更多相关文章
- hdu 5881 Tea (2016 acm 青岛网络赛)
原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5881 Tea Time Limit: 3000/1000 MS (Java/Others) Me ...
- 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 5884 Sort(2016年青岛网络赛 G 二分+贪心+小优化)
好题 题意:给你n<=100000个数,每个数范围[0,1000],然后给你一个最大的代价T,每次最多合并k个数成为一个数,代价为k个数的总和.问最后合成1个数的总代价不大于T的最小k 题解:我 ...
- HDU 5880 Family View (2016 青岛网络赛 C题,AC自动机)
题目链接 2016 青岛网络赛 Problem C 题意 给出一些敏感词,和一篇文章.现在要屏蔽这篇文章中所有出现过的敏感词,屏蔽掉的用$'*'$表示. 建立$AC$自动机,查询的时候沿着$fa ...
- 2016 ACM/ICPC Asia Regional Qingdao Online(2016ACM青岛网络赛部分题解)
2016 ACM/ICPC Asia Regional Qingdao Online(部分题解) 5878---I Count Two Three http://acm.hdu.edu.cn/show ...
- HDU 5886 Tower Defence(2016青岛网络赛 I题,树的直径 + DP)
题目链接 2016 Qingdao Online Problem I 题意 在一棵给定的树上删掉一条边,求剩下两棵树的树的直径中较长那的那个长度的期望,答案乘上$n-1$后输出. 先把原来那棵树的 ...
- HDU - 5878 2016青岛网络赛 I Count Two Three(打表+二分)
I Count Two Three 31.1% 1000ms 32768K I will show you the most popular board game in the Shanghai ...
- HDU - 5887 2016青岛网络赛 Herbs Gathering(形似01背包的搜索)
Herbs Gathering 10.76% 1000ms 32768K Collecting one's own plants for use as herbal medicines is pe ...
随机推荐
- 我所了解的chrome
Chrome的隐身模式 先来说说隐身模式的启用方法吧 1.键盘快捷:Ctrl + Shift + N. 2.在Windows7下的任务栏处,右击“Chrome”图标,会出一个下拉菜单,点击“新建隐身窗 ...
- Atitit RSA非对称加密原理与解决方案
Atitit RSA非对称加密原理与解决方案 1.1. 一.一点历史 1 1.2. 八.加密和解密 2 1.3. 二.基于RSA的消息传递机制 3 1.4. 基于rsa的授权验证机器码 4 1.5. ...
- Linux初学 - 文件夹及文件操作
创建文件夹 mkdir 移动文件夹 mv dir1 dir2 复制文件夹 cp 删除文件夹 rm 创建文件 touch 编辑文件内容 vi /vim 查看文件内容 cat 追加文件内容 echo 复制 ...
- javascript_core_08之闭包、对象、原型
1.闭包: ①外层函数包裹受保护的变量和操作变量的内层函数: ②外层函数将内层函数返回到外部: ③调用外部函数,获得内层函数的对象: 2.面向对象:用对象描述现实一个具体事物属性和功能,按需调用功能, ...
- ViewPager做图片浏览器,加载大量图片OOM的问题修正
/** * @author CHQ * @version 1.0 * @date 创建时间: 2016/7/26 17:18 * @parameter * @return * 图片查看器 * //可以 ...
- png图片制作任意颜色的小图标
本内容只要是对张鑫旭PNG格式小图标的CSS任意颜色赋色技术的这篇文章进行详细说明. HTML: <i class="icon"><i class="i ...
- 深入理解CSS元素可见性visibility
× 目录 [1]定义 [2]属性 [3]display[4]JS[5]transition [6]API[7]DEMO 前面的话 visibility属性常见于与display属性的比较中.但实际上, ...
- HTML5之废弃和更新的元素与属性
废弃的元素和属性 [1]标签替换 <acronym> 替代:<abbr> <applet> 替代:<embed> 或 <object> &l ...
- poj 2777(线段树的节点更新策略)
/* 之前的思想是用回溯的方式进行颜色的更新的!如果用回溯的方法的话,就是将每一个节点的颜色都要更新 通过子节点的颜色情况来判断父节点的颜色情况 !这就是TLE的原因! 后来想一想没有必要 !加入[a ...
- Socket桥(转载)
最好方案:使用haproxy 或者nginx转发.自己写程序性能和监控难保证,推荐使用开源软件替代. 源地址为:http://baishaobin2003.blog.163.com/blog/stat ...