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就 ...
随机推荐
- Caffe学习系列(2):数据层及参数
要运行caffe,需要先创建一个模型(model),如比较常用的Lenet,Alex等, 而一个模型由多个屋(layer)构成,每一屋又由许多参数组成.所有的参数都定义在caffe.proto这个文件 ...
- 图片加载框架Picasso解析
picasso是Square公司开源的一个Android图形缓存库 主要有以下一些特性: 在adapter中回收和取消当前的下载: 使用最少的内存完成复杂的图形转换操作: 自动的内存和硬盘缓存: 图形 ...
- ZH奶酪:Java调用NLPIR汉语分词系统
NLPIR工具 支持自定义词表: 可以离线使用: 下载地址:http://ictclas.nlpir.org/newsdownloads?DocId=389 在线演示:http://ictclas.n ...
- servlet乱码问题总结
在学习时servlet乱码问题还是挺严重的,总结一下有三种情况 1.新建HTML页面后浏览出现乱码 2.以post形式请求时出现乱码 3.以get形式请求时出现乱码 让我们一个一个来解决吧 1.新建H ...
- window.location.href = window.location.href 跳转无反应 a 超链接 onclick 点击跳转无反应
错误写法 , 主要是在 href="#"这里 <a href="#" id="send" onclick="return b ...
- PRML读书会第九章 Mixture Models and EM(Kmeans,混合高斯模型,Expectation Maximization)
主讲人 网络上的尼采 (新浪微博: @Nietzsche_复杂网络机器学习) 网络上的尼采(813394698) 9:10:56 今天的主要内容有k-means.混合高斯模型. EM算法.对于k-me ...
- leetcode - 位运算题目汇总(上)
最近在看位运算的知识,十分感叹于位运算的博大精深,正好leetcode有 Bit Manipulation 的专题,正好拿来练练手. Subsets 给出一个由不同的数字组成的数组,枚举它的子数组(子 ...
- GitHub: Windows 下的简单使用
这段时间在博客园多了很多关于GitHub的文章,但是我的确没怎么看懂.不过这几天简单的看了写资料,亲身操作之后也有了一点体会.这算是最简单的GitHub入门了吧,基本全是鼠标操作.这也是这几天的总结, ...
- md5加密篇(一)
/// <summary> /// 获取文件的md5摘要 /// </summary> /// <param name="sFile">文件流& ...
- SQL-Server下载地址
有同学费尽心思的找SQL server数据库各版本的下载地址,看到别人的求助贴就不自觉的想去帮助他们,但是一个一个去帮助又不太现实,毕竟个人精力有限,既然大家有需求,那么艾薇百科今天就本着乐于分享和奉 ...