2016第三场多校联盟训练1010
来源:互联网 发布:安卓画图软件 编辑:程序博客网 时间:2024/06/05 10:12
Windows 10
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 786 Accepted Submission(s): 239
Problem Description
Long long ago, there was an old monk living on the top of a mountain. Recently, our old monk found the operating system of his computer was updating to windows 10 automatically and he even can't just stop it !!
With a peaceful heart, the old monk gradually accepted this reality because his favorite comic LoveLive doesn't depend on the OS. Today, like the past day, he opens bilibili and wants to watch it again. But he observes that the voice of his computer can be represented as dB and always be integer.
Because he is old, he always needs 1 second to press a button. He found that if he wants to take up the voice, he only can add 1 dB in each second by pressing the up button. But when he wants to take down the voice, he can press the down button, and if the last second he presses the down button and the voice decrease x dB, then in this second, it will decrease 2 * x dB. But if the last second he chooses to have a rest or press the up button, in this second he can only decrease the voice by 1 dB.
Now, he wonders the minimal seconds he should take to adjust the voice from p dB to q dB. Please be careful, because of some strange reasons, the voice of his computer can larger than any dB but can't be less than 0 dB.
With a peaceful heart, the old monk gradually accepted this reality because his favorite comic LoveLive doesn't depend on the OS. Today, like the past day, he opens bilibili and wants to watch it again. But he observes that the voice of his computer can be represented as dB and always be integer.
Because he is old, he always needs 1 second to press a button. He found that if he wants to take up the voice, he only can add 1 dB in each second by pressing the up button. But when he wants to take down the voice, he can press the down button, and if the last second he presses the down button and the voice decrease x dB, then in this second, it will decrease 2 * x dB. But if the last second he chooses to have a rest or press the up button, in this second he can only decrease the voice by 1 dB.
Now, he wonders the minimal seconds he should take to adjust the voice from p dB to q dB. Please be careful, because of some strange reasons, the voice of his computer can larger than any dB but can't be less than 0 dB.
Input
First line contains a number T (1≤T≤300000 ),cases number.
Next T line,each line contains two numbersp and q (0≤p,q≤109)
Next T line,each line contains two numbers
Output
The minimal seconds he should take
Sample Input
21 57 3
Sample Output
44
http://acm.hdu.edu.cn/showproblem.php?pid=5802
问题概述:音响实际音量A,目标音量B,如果你一直按着up键,那么每秒音量会提升1点,如果你一直按着down
键,那么每秒音量会降低2^(t-1)点,如果你中途停下1s或者按了一下up键,那么t就会初始化为1,请问从起始音量
到目标音量至少要按多少秒?
每次都有两个抉择:
①一直按↓直到音量刚好小于等于目标音量,然后再一直按↑,注意按↑的时间要减去之前停顿的时间
②一直按↓到音量只要多按1s就会小于目标音量,停顿1s,继续按↓
DFS
#include<stdio.h>#include<algorithm>using namespace std;int Sech(int S, int T, int step, int stop){int x, temp, sum;if(S==T) return step;x = 1, sum = 0;while(S-x+1>T)x *= 2, sum++;if(S-x+1==T)return step+sum;temp = sum+max(0, T-max(0, S-x+1)-stop);return min(temp+step, Sech(S-x/2+1, T, step+sum, stop+1));}int main(void){int T, a, b;scanf("%d", &T);while(T--){scanf("%d%d", &a, &b);if(b>=a)printf("%d\n", b-a);elseprintf("%d\n", Sech(a, b, 0, 0));}return 0;}
1 0
- 2016第三场多校联盟训练1010
- 2016第三场多校联盟训练1010
- 2016第三场多校联盟训练1003
- 2016第三场多校联盟训练1003
- 2016第三场多校联盟训练1011
- 2016第三场多校联盟训练1011 Teacher Bo(曼哈顿距离)
- 2016第三场多校联盟1001
- 2016第三场多校联盟1002
- 第九周 oj训练 大帆玩英雄联盟
- 程序员互动联盟第三届第一题
- 2016多校联合训练赛 第三场1010 Rower Bo hdu 5761
- 2015-2016 下半学期 第三周 训练
- 训练第三周之dp-背包训练
- 联盟
- 第三周项目训练四
- 第三场个人训练赛
- 第三场个人训练赛
- 第三场训练赛总结
- 编程之美3.2电话号码对应英语单词 java版
- iOS PEM证书
- 搭建web服务器之Apache服务器简单搭建过程记录
- hdoj 1285 确定比赛名次 ( 拓扑排序--三种模板 )
- 连接池
- 2016第三场多校联盟训练1010
- 电脑问题勘查 —— BIOS
- STL源码阅读(六)
- 连上公众wifi,但是找不到登陆界面怎么办?
- javascript继承的几种方式
- crontan命令自动发送邮件
- centos7.2部署svn服务器
- Spring MVC 1.2
- C++类构造函数初始化列表执行顺序