HDU 5802 Windows 10
Windows 10
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 694 Accepted Submission(s): 200
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 $2x$ 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\le T\le 300000)$,cases number.
Next $T$ line,each line contains two numbers $p$ and $q (0\le p,q\le 10^9)$.
1 5
Implementation
#include <bits/stdc++.h>
using namespace std; int res, p, q, s[], T; void dfs(int x, int p, int sub){
if(p+sub>=res) return;
int i=lower_bound(s, s+, x)-s, r=s[i]-x;
res=min(res, p+sub+i+max(, min(q, r-p)));
if(r) dfs(x-s[i-], p+, sub+i-);
} int main(){
for(int i=; i<; i++)
s[i]=(1LL<<i)-; for(cin>>T; T--; ){
scanf("%d%d", &p, &q);
if(p<=q) res=q-p;
else res=INT_MAX, dfs(p-q, , );
printf("%d\n", res);
}
}
HDU 5802 Windows 10的更多相关文章
- hdu 5802 Windows 10 贪贪贪
传送门:hdu 5802 Windows 10 题意:把p变成q:升的时候每次只能升1,降的时候如果前一次是升或者停,那么下一次降从1开始,否则为前一次的两倍 官方题解: 您可能是正版Windows ...
- HDU 5802 Windows 10 (贪心+dfs)
Windows 10 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5802 Description Long long ago, there was ...
- hdu 5802 Windows 10 (dfs)
Windows 10 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- 2016暑假多校联合---Windows 10
2016暑假多校联合---Windows 10(HDU:5802) Problem Description Long long ago, there was an old monk living on ...
- hdu5802 Windows 10 贪心
Windows 10 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- 获取微软原版“Windows 10 推送器(GWX)” 卸载工具
背景: 随着Windows 10 免费更新的结束,针对之前提供推送通知的工具(以下简称GWX)来说使命已经结束,假设您还未将Windows 8.1 和Windows 7 更新到Windows 10 的 ...
- Windows 10 部署Enterprise Solution 5.5
Windows 10正式版发布以后,新操作系统带来了许多的变化.现在新购买的电脑安装的系统应该是Windows 10.与当初用户不习惯Windows 7,购买新电脑后第一个想做的事情就是重装成XP,估 ...
- 如何通过官方渠道为Windows 10 添加具有中国特色的字体
Windows 10的变化细节上个人认为要比Windows 8多很多,而且很多功能找到之后还是小惊喜,就是挺多好用的地方居然都不正经宣传一下,微软真是搞得悄悄地干活? 今天为大家介绍一下通过官方途径添 ...
- 如何修复Windows 10 Enterprise 在9月更新后图片全部由绘图板打开的情况
在进行了本月更新日的洗礼之后,企业版的Windows 10 突然发现无法好好的进行图片查看. 因为更新之前,各种图片都是使用“照片程序”打开的(这个是photos app),然后更新之后,这个app就 ...
随机推荐
- MySql 中文乱码排查解决方案
MySQL会出现中文乱码的原因不外乎下列几点: server本身设定问题,例如还停留在latin1 table的语系设定问题(包含character与collation) 客户端程式(例如php)的连 ...
- 《DOM启蒙》 随笔
使用 Javascript 字符串创建并向 DOM 中添加元素与文本节点 innerHTML.outerHTML.textContent 及 insertAdjacentHTML() 属性和方法提供了 ...
- JavaScript文件加载器LABjs API详解
在<高性能JavaScript>一书中提到了LABjs这个用来加载JavaScript文件的类库,LABjs是Loading And Blocking JavaScript的缩写,顾名思义 ...
- NPOI2.0学习(二)
如果你要编辑的行和单元格,原本没有值,或者从未创建过的,就必须先创建. //在第二行创建行 IRow row = sheet.CreateRow(); //在第二行的第一列创建单元格 ICell ce ...
- nios II--实验2——led硬件部分
Led 硬件开发 新建原理图 1.打开Quartus II 11.0,新建一个工程,File -> New Project Wizard…,忽略Introduction,之间单击 Next> ...
- We Know What @You #Tag: Does the Dual Role Affect Hashtag Adoption-20160520
分析类的论文 1.Information publication:www2012 author: Mei qiao zhu 2.What 微博中的hashtag既可以表示谈论的内容,又可以代表一个群体 ...
- 60-chmod 修改文件的权限
修改文件的权限 chmod [options] who operator permission file-list (符号模式) chmod [options] mode file-list (绝对模 ...
- git 最常用命令
新建分支 git branch a #分支名称为a 切换到develop分支 git checkout a 新建分支并切换 git checkout -b a 推送到远程分支 git push ori ...
- IntelliJ_13_配置tomcat
一.下载tomcat7并解压 http://tomcat.apache.org/download-70.cgi http://apache.fayea.com/tomcat/tomcat-7/v7.0 ...
- 关于二叉排序树 BST
#include<stdio.h> #include<stdlib.h> typedef struct node { double w; struct node *l,*r; ...