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 LL.
The exact volume of tea is at most RR.
Alice put two empty cups between you and her.
Alice wants the two cups filled by almost equal volume of tea.
Yours cannot be 11 unit more than hers.
Hers cannot be 11 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 11 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.
InputThere are multiple cases.
For each case, there is one line of two integers LL and RR, separated by single space.
Here are some analyses about sample cases.
For the first case, pouring 11 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.51.5 units into one cup, then you attempt to pour another 1.51.5 units into the other cup.
Since the lower bound is 22, at least 0.50.5 unit remains in the pot after the first pouring.
If the initial volume is in range [2,3][2,3], the second cup will have volume in range [0.5,1.5][0.5,1.5] which is balanced with 1.51.5 unit in the first cup, and at most 11 unit remain after these two attempts.
About 10001000 test cases, and 0≤L≤R≤10160≤L≤R≤1016.OutputFor 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 题目非常的长 实际有用的不多
题意:
一个茶壶 两个杯子 茶壶里面的茶的容积在[L,R]之间,
将茶壶里面的茶倒入杯子里面,(要求两个杯子里面的茶体积不能差 1升以上,
而且最后茶壶里面的茶也不能多余1升)
求出最少要倒多少次? 这题是题意非常难以理解,不知道茶壶里面的体积具体为多少,在[L,R]之间,
所以说一次倒2L是最快的,先要使一个杯子里面的茶比另外一个杯子里面的茶多1L
然后一次倒2L
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int main() {
long long L,R;
while(scanf("%lld%lld",&L,&R)!=EOF){
long long sum;
if (R<=) sum=;
else if (R<=) sum=;
else {
if (L==) sum=(R+)/;
else {
sum=(R-L)/+;
if (sum<) sum=;
}
}
printf("%lld\n",sum);
}
return ;
}