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 ...
随机推荐
- ylbtech-WelfareSystem(福利发放管理系统)-数据库设计
ylbtech-DatabaseDesgin:ylbtech-WelfareSystem(福利发放管理系统)-数据库设计 1.A,数据库关系图(Database Diagram) 1.B,数据库设计脚 ...
- 彻底解决DZ大附件上传问题
个. 注意:很多人遇到修改php.ini后重应WEB服务后仍然不能生效.这种情况应该先确认一下所改的php.ini是不是当前PHP所使用的.您可以在WEB目录下建立一个php文件,内容很简单就一句话& ...
- JAVA之继承的必要性
//说明继承的必要性package com.test; public class test { /** * @param args */ public static void m ...
- django模型manager学习记录
Managers 在语句Book.objects.all()中,objects是一个特殊的属性,需要通过它查询数据库. 在第5章,我们只是简要地说这是模块的manager .现在是时候深入了解mana ...
- 在自己的网站上使用RSS订阅功能
要增加RSS订阅功能其实很简单 就是填写一个规定好的xml文档,按照要求填好就可以实现 具体的步骤如下: 这是在网上查到的RSSxml文档 <?xml version="1.0&quo ...
- Android源代码下载
清华大学AOSP镜像: https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
- #淘宝#复制分享宝贝内容,打开淘宝APP,自己主动弹出宝贝提示信息
场景描写叙述: 淘宝复制连接,分享出去,比方拷贝到QQ好友.微信好友,一个宝贝信息.然后你朋友长按复制你分享它了的这个宝贝.当然打开手机淘宝时.自己主动会跳出宝贝的信息,点击确定能够直接进入宝贝详情 ...
- uva507 - Jill Rides Again(最长连续和)
option=com_onlinejudge&Itemid=8&page=show_problem&problem=448">题目:uva507 - Jill ...
- javascript 冒泡排序算法
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- Nginx:HTTP框架是如何介入请求
参考资料 <深入理解Nginx>(陶辉) Nginx事件模块博客地址:http://www.cnblogs.com/runnyu/p/4914698.html Nginx是一个事件驱动构架 ...