hdu5802 Windows 10 贪心
Windows 10
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2096 Accepted Submission(s): 630
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.
Next T line,each line contains two numbers p and q (0≤p,q≤109)
1 5
7 3
4
/**
题目: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 贪心的更多相关文章
- hdu-5802 Windows 10(贪心)
题目链接: Windows 10 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 多校6 1010 HDU5802 Windows 10 dfs
// 多校6 1010 HDU5802 Windows 10 // 题意:从p到q有三种操作,要么往上升只能1步,要么往下降,如果连续往下降就是2^n, // 中途停顿或者向上,下次再降的时候从1开始 ...
- 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
传送门 Windows 10 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- hdu 5802 Windows 10 贪贪贪
传送门:hdu 5802 Windows 10 题意:把p变成q:升的时候每次只能升1,降的时候如果前一次是升或者停,那么下一次降从1开始,否则为前一次的两倍 官方题解: 您可能是正版Windows ...
- 获取微软原版“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就 ...
随机推荐
- 一个简单的WeakList的实现
有的时候,我们会使用到WeakList,它和传统的List不同的是,保存的是对象的弱应用,在WeakList中存储的对象会被GC回收,在一些和UI相关的编程的地方会用到它(弱事件,窗体的通知订阅等). ...
- Android2017进阶知识点、面试题及答案(精选版)
前言 没啥好说的,撸起袖子就是干吧! 1 2 JAVA 相关 1.静态内部类.内部类.匿名内部类,为什么内部类会持有外部类的引用?持有的引用是this?还是其它? 静态内部类:使用static修饰的内 ...
- 用Thunderbird以HTML发邮件,收件人却总是收到文本邮件
要在通讯录里面,把你要发送的人设置可以接收HTML格式的邮件,那么你才能发出HTML格式. 否则,Thunderbird默认你所发的收件人无法接收HTML格式邮件.
- HTMLTestRunner美化
https://www.cnblogs.com/findyou/p/6925733.html 参考这个,美化的不错,进入了汉化,及加入了一些样式,
- javascript快速入门6--Script标签与访问HTML页面
Script标签 script标签用于在HTML页面中嵌入一些可执的脚本 <script> //some script goes here </script> script标签 ...
- Python图像处理(8):边缘检測
快乐虾 http://blog.csdn.net/lights_joy/ 欢迎转载,但请保留作者信息 此前已经得到了单个区域植株图像,接下来似乎应该尝试对这些区域进行分类识别.通过外形和叶脉进行植物种 ...
- Laravel系列教程一:安装及环境配置
免费视频教程地址https://laravist.com/series/laravel-5-basic 最近在SF上面看到越来越多的Laravel相关的问题,而作为一个Laravel的脑残粉,本来打算 ...
- EasyUI-DataGrid动态合并单元格
js /** * EasyUI DataGrid根据字段动态合并单元格 * @param fldList 要合并table的id * @param fldList 要合并的列,用逗号分隔(例如:&qu ...
- Python下opencv使用笔记(二)(简单几何图像绘制)
简单几何图像一般包含点.直线.矩阵.圆.椭圆.多边形等等.首先认识一下opencv对像素点的定义. 图像的一个像素点有1或者3个值.对灰度图像有一个灰度值,对彩色图像有3个值组成一个像素值.他们表现出 ...
- 对AOP切面的一些整理与理解
首先上一张AOP的图示 一:几个重要的概念 1> 切面:横切关注点(跨越应用程序多个模块的功能)被模块化的特殊对象[验证切面.日志切面] 2> 通知:切面中的每个方法 3& ...