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 ;
}

hdu5802 Windows 10 贪心的更多相关文章

  1. hdu-5802 Windows 10(贪心)

    题目链接: Windows 10 Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others ...

  2. 多校6 1010 HDU5802 Windows 10 dfs

    // 多校6 1010 HDU5802 Windows 10 // 题意:从p到q有三种操作,要么往上升只能1步,要么往下降,如果连续往下降就是2^n, // 中途停顿或者向上,下次再降的时候从1开始 ...

  3. HDU 5802 Windows 10 (贪心+dfs)

    Windows 10 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5802 Description Long long ago, there was ...

  4. HDU 5802 Windows 10

    传送门 Windows 10 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  5. hdu 5802 Windows 10 贪贪贪

    传送门:hdu 5802 Windows 10 题意:把p变成q:升的时候每次只能升1,降的时候如果前一次是升或者停,那么下一次降从1开始,否则为前一次的两倍 官方题解: 您可能是正版Windows ...

  6. 获取微软原版“Windows 10 推送器(GWX)” 卸载工具

    背景: 随着Windows 10 免费更新的结束,针对之前提供推送通知的工具(以下简称GWX)来说使命已经结束,假设您还未将Windows 8.1 和Windows 7 更新到Windows 10 的 ...

  7. Windows 10 部署Enterprise Solution 5.5

    Windows 10正式版发布以后,新操作系统带来了许多的变化.现在新购买的电脑安装的系统应该是Windows 10.与当初用户不习惯Windows 7,购买新电脑后第一个想做的事情就是重装成XP,估 ...

  8. 如何通过官方渠道为Windows 10 添加具有中国特色的字体

    Windows 10的变化细节上个人认为要比Windows 8多很多,而且很多功能找到之后还是小惊喜,就是挺多好用的地方居然都不正经宣传一下,微软真是搞得悄悄地干活? 今天为大家介绍一下通过官方途径添 ...

  9. 如何修复Windows 10 Enterprise 在9月更新后图片全部由绘图板打开的情况

    在进行了本月更新日的洗礼之后,企业版的Windows 10 突然发现无法好好的进行图片查看. 因为更新之前,各种图片都是使用“照片程序”打开的(这个是photos app),然后更新之后,这个app就 ...

随机推荐

  1. apk打包

    1.在导航栏中选择Builder->Generate Signed Apk 2.新建点击Creat new... 3.注意路径后面写apk的名字(这个名字将会显示在手机软件的下方)

  2. xib中Autolayout的使用

    压缩包下载链接:http://share.weiyun.com/ceb6107857789ae3ec08d4a83269713d (密码:Kd33)

  3. 我是如何给discuz模板做语法高亮的/vs code/textmate

    本人一直做ASP.NET开发,近期接到任务要用Discuz开发一个社区,第一次接触PHP,PHP灵活的语法,天生的模块化,各种语法糖深深的震惊了我,我从内心深处感受到了PHP是最牛逼的语言!!! 好了 ...

  4. LiDAR Textbook & Automated Road Network Extraction

    Original article published here, Posted on March 18, 2009 by lidar A positive feedback loop is begin ...

  5. Android线程与线程池

    引言 在Android中,几乎完全采用了Java中的线程机制.线程是最小的调度单位,在很多情况下为了使APP更加流程地运行,我们不可能将很多事情都放在主线程上执行,这样会造成严重卡顿(ANR),那么这 ...

  6. EL表达式介绍(2)

    1. EL关系运算符: 关系运算符 说明 范例 结果 == 或 eq 等于 ${5==5}或${5eq5} true != 或 ne 不等于 ${5!=5}或${5ne5} false < 或 ...

  7. Android手掌抑制功能的实现

    近期须要实现一个功能,在Activity中有一个手写区域,为了更好的用户体验,须要满足即使整个手掌放在屏幕上时(android平板,屏幕比較大)也仅仅响应手写区域内的操作,即在支持多点触控的情况下,仅 ...

  8. 实现Xshell断开连接情况下Linux命令继续执行

    1.将原命令语句改为:nohup 命令语句 & 2.回车执行,再回车,窗口中会显示一个进程号 3.如果中途想关闭,可执行:kill -9 进程号.如果想查看命令执行情况,可执行:cat noh ...

  9. 阿里云部署Java web项目初体验

    林炳文Evankaka原创作品. 转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要讲了怎样在阿里云上安装JDK.Tomcat以及其配置过程. 最后以一个实例来演 ...

  10. MPTCP 源码分析(五) 接收端窗口值

    简述:      在TCP协议中影响数据发送的三个因素分别为:发送端窗口值.接收端窗口值和拥塞窗口值. 本文主要分析MPTCP中各个子路径对接收端窗口值rcv_wnd的处理.   接收端窗口值的初始化 ...