日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【HDU - 5881】Tea(思维,找规律)

發(fā)布時(shí)間:2023/12/10 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【HDU - 5881】Tea(思维,找规律) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題干:

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

Input

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

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

題目大意:

有一壺水, 體積在?L?和?R?之間, 有兩個(gè)杯子, 你要把水倒到兩個(gè)杯子里面, 使得杯子水體積幾乎相同(體積的差值小于等于1), 并且使得壺里剩下水體積不大于1. 你無法測量壺里剩下水的體積, 問最小需要倒水的次數(shù)。

解題報(bào)告:

就是個(gè)找規(guī)律題,沒啥意思,為了保險(xiǎn)就特判了一堆。

第一次倒給第一個(gè)杯子L/2+0.5是比較合適的,第二次倒給第二個(gè)杯子L/2+0.5+1,再給第一個(gè)杯子倒2L,繼續(xù)這樣直到壺只剩小于等于1L。

最后的公式就是 (R - L) / 2 ?+ 1。

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define F first #define S second #define ll long long #define pb push_back #define pm make_pair using namespace std; typedef pair<int,int> PII; const int MAX = 2e5 + 5;int main() {ll l,r;while(~scanf("%lld%lld",&l,&r)) {if(r <= 1) puts("0");else if(r <= 2) puts("1");else if(l == 0) {printf("%lld\n",(r-1)/2 + 1);}else if(l == r || l+1 == r|| l+2==r) puts("2");else {printf("%lld\n",1+(r-l)/2);}}return 0 ; }

?

總結(jié)

以上是生活随笔為你收集整理的【HDU - 5881】Tea(思维,找规律)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 一级二级三级黄色片 | 国产精品天天av精麻传媒 | 久久99精品久久只有精品 | 青青草综合在线 | 成人字幕 | 黄色网址最新 | 国产精品永久免费视频 | 狠狠躁夜夜躁人人爽视频 | 在线观看国产一级片 | 色爽视频 | 性猛交xxxx乱大交3 | 一女双乳被两男吸视频 | 五月天丁香激情 | 人人妻人人爽欧美成人一区 | 欧美黄色小说 | 国产一区二区视频网站 | 国产精品福利在线播放 | 成人做爰免费视频免费看 | 国产一级全黄 | 国产精品久久久久久久久免费软件 | 国产xxx视频| 激情小说激情视频 | 99久久黄色 | 美女羞羞动态图 | 国产原创在线观看 | 中文字幕 日韩有码 | 国产精品成人一区 | 日本理论片 | 青娱乐99| 先锋影音亚洲 | 伊人网综合在线 | 亚洲精品粉嫩小泬20p | 日日射射 | 国内精品久久久久久久久久 | 日日操夜夜爽 | 99热一区二区 | 日本黄色aaa | 香蕉视频网站在线 | 日韩精品av一区二区三区 | 一级理论片 | 日韩欧美在线一区二区三区 | 成人不卡av| 超碰在线综合 | 国产成人免费在线观看 | 视频黄色免费 | 亚洲老妇色熟女老太 | 国产欧美又粗又猛又爽 | av天天操| 偷拍第一页 | 97干在线 | www,xxx69 japan| exo妈妈mv在线播放免费 | 国产做受麻豆动漫 | 男女性生活毛片 | 99爱爱视频| 国产精品色片 | 亚洲一区二区三区中文字幕 | 日韩精品中文字幕一区 | 99小视频 | 国产不卡二区 | 无码人妻丰满熟妇精品区 | 青青久操 | 国产真实生活伦对白 | 男女啪啪十八 | 国产成人 综合 亚洲 | 黑人爱爱视频 | 亚洲精品在线电影 | 欧美性受xxx黑人xyx性爽 | 丁香花电影在线观看免费高清 | 蓝牛av| 操丰满女人 | 超碰人人在线 | 蜜桃导航-精品导航 | 老牛影视少妇在线观看 | 好色先生tv官网 | 久久爱成人 | 娇妻之欲海泛舟无弹窗笔趣阁 | 国产爆操视频 | 在线观看黄色国产 | 解开乳罩喂领导吃奶 | 中文字幕一区二区人妻痴汉电车 | 免费日韩av| 精产国品一区二区 | 亚洲乱视频 | 911香蕉 | 午夜视频日韩 | 狠狠躁天天躁综合网 | 日韩毛片在线免费观看 | 欧美视频在线免费 | 欧美日韩在线观看一区 | 亚洲国产日韩a在线播放性色 | 亚洲女人毛片 | 亚洲桃色av| 亚洲激情六月 | 亚洲 欧美 变态 另类 综合 | 三级在线观看 | 高清视频一区二区 | 午夜网站视频 | 999精品在线观看 |