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 ...
随机推荐
- Python学习--06切片
Python里提供了切片(Slice)操作符获取列表里的元素. 示例: >>> L = [1,2,3,4,5] # 取前2个元素,传统方法 >>> [L[0],L[ ...
- 第四节:Vue表单标签和组件的基本用法,父子组件间的通信
vue表单标签和组件的基本用法,父子组件间的通信,直接看例子吧. <!DOCTYPE html> <html> <head> <meta charset=&q ...
- chrome开发总结(交互/权限/存储)-爬虫
chrome开发总结(交互/权限/存储)-爬虫 [TOC] 标签(空格分隔): 杂乱之地 经过一翻折腾.还是选择了chrome来做爬虫.主要是为了解决一些ajax加载的问题以及代理的问题. 1.chr ...
- Cocos2d-x 3.2 学习笔记(五)Sprite Node
游戏中最重要的元素Sprite精灵,关于精灵的创建,精灵的控制等等. 涉及到的类Class: AnimationFrame 动画帧. Animation 动画对象:一个用来在精灵对象上表现动画的动画对 ...
- 简明 Git 命令速查表
本文总结了git常用的命令,以便学习者使用时查阅~ 几个专用名词的译名如下 Workspace:工作区 Index / Stage:暂存区 Repository:仓库区(或本地仓库) Remote ...
- 轻松自动化---selenium-webdriver(python) (一)
为什么选python? 之前的菜鸟系列是基于java的,一年没学其实也忘的差不多了,目前所测的产品部分也是python写的,而且团队也在推广python ,其实就测试人员来说,python也相当受欢迎 ...
- Network - FTP与SFTP
FTP --- FTP File Transfer SFTP --- SSH File Transfer 缩写 名称 协议与端口 安全策略 特征描述 守护进程(linux) 应用场景 SFTP SSH ...
- Nutch源码阅读进程4---parseSegment
前面依次看了nutch的准备工作inject和generate部分,抓取的fetch部分的代码,趁热打铁,我们下面来一睹parse即页面解析部分的代码,这块代码主要是集中在ParseSegment类里 ...
- 生成二维码的方法,基于zxing
现在生活中常用了一些二维码,这些在现实生活中已经非常密切了,那么怎么使用java来产生一个二维码呢? 下面给出代码 首先给出一个工具类,这里包含了生成二维码的图片对象,保存到流中,或者文件中: pac ...
- Kibana中doc与search策略的区别
在kibana中包含两种策略:doc和search.使用了两个循环队列来获取请求,并进行响应. doc的代码如下: clientMethod: 'mget' search的代码如下: clientMe ...