Windows 10

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2096    Accepted Submission(s): 630

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.
 
Input
First line contains a number T (1≤T≤300000),cases number.
Next T line,each line contains two numbers p and q (0≤p,q≤109)
 
Output
The minimal seconds he should take
 
Sample Input
2
1 5
7 3
 
Sample Output
4
4
 
Author
UESTC
 
Source
/**
题目:hdu5802 Windows 10
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5802
题意:调节音量p到q,上升音量每秒只能上升1,下降音量每秒为2*x,x为上一次下降的音量,如果下降时休息或者上升音量则x置为1,音量最低为0
题意有问题:题目说p不能降为负数。但是如果p-x<0;那么可以把p-x<0的结果都看做p-x==0; 思路:贪心的去选,每次下降到终点上的最近一点,或者终点下的一点,取得一个最小值就好。 */ #include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int mod=1e9+;
const int maxn=1e6+;
const double eps = 1e-;
LL dfs(LL p,LL q,LL delay)
{
LL x = ;
LL cnt = ;
while(p-x>=q){
cnt++;
p = p-x;
x = x*;
}
if(p==q) return cnt;
return min(max(0LL,q-max(0LL,(p-x))-delay)+cnt+,dfs(p,q,delay+)+cnt+); }
int main()
{
int T;
LL p, q;
cin>>T;
while(T--)
{
scanf("%lld%lld",&p,&q);
if(p<q){
printf("%lld\n",q-p);
}else
{
printf("%lld\n",dfs(p,q,));
}
} return ;
}

最新文章

  1. 设计模式UML类图基础
  2. php上传文件大小限制
  3. bin(x) 将整数x转换为二进制字符串
  4. linux下安装php扩展redis缓存
  5. poj3519
  6. 委托、 Lambda表达式和事件——委托
  7. 第一个程序 - Windows程序设计(SDK)001
  8. ffplay2 android 版正式公布
  9. MongoDB的upsert状态判断和pymongo使用方法
  10. C# 添加、获取及删除PDF附件
  11. scrapy跟pyspider的杂谈
  12. java 中String类的常用方法总结,带你玩转String类。
  13. [poj2451]Uyuw&#39;s Concert
  14. Java 8新特性:新语法方法引用和Lambda表达式及全新的Stream API
  15. 自定义ViewGroup添加布局动画
  16. Linux操作汇总
  17. Nginx 安装与详解
  18. prometheus + grafana安装部署(centos6.8)
  19. Maven -Maven配置tomcat插件 两种
  20. 回头探索JDBC及PreparedStatement防SQL注入原理

热门文章

  1. 制作推送证书 and Code=3000 &quot;未找到应用程序的“aps-environment”的权利字符串&quot;
  2. Oracle RAC 环境下的 v$log v$logfile
  3. 修改input type=file 标签默认样式的简单方法
  4. java通过Comparable接口实现字符串比较大小排序的简单实例
  5. 【spring data jpa】jpa实现update操作 字段有值就更新,没值就用原来的
  6. jquery.mobile 中 collapsible-set collapsible listview 共同布局问题
  7. Linux环境下安卓SDK和ADT下载地址下载地址
  8. javascriptMVC框架面向对象编程
  9. C#中抽象方法与虚方法的区别
  10. Python \xd7\xaa\xd5\xbdOTT TV\xb1\xa6\xbd\xe0 编码