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 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.

InputThere are multiple cases. 
For each case, there is one line of two integers 0≤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


 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 
 6 int main() {
 7     long long L,R;
 8     while(scanf("%lld%lld",&L,&R)!=EOF){
 9         long long sum;
10         if (R<=1) sum=0;
11         else if  (R<=2) sum=1;
12         else {
13             if (L==0) sum=(R+1)/2;
14             else {
15                 sum=(R-L)/2+1;
16                 if (sum<2) sum=2;
17             }
18         }
19         printf("%lld\n",sum);
20     }
21     return 0;
22 }

 



相关文章: