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就 ...
随机推荐
- INLINE-BLOCK和FLOAT(二)(转)
一.一抹前言 没有爱的日子,时间如指尖细沙,不知不觉就流逝了.写“CSS float浮动的深入研究.详解及拓展(一)”和“CSS float浮动的深入研究.详解及拓展(二)”似乎就在不久前,然而相隔差 ...
- Mac Screen Capture Shortcuts
Here's How: To capture the entire desktop, press Command-Shift-3. The screen shot will be automati ...
- 重大新闻:腾讯大杀器来了,QQ浏览器微信版推出
今日,腾讯在推出windows桌面版的微信后,又发布了一个重量级产品:QQ浏览器微信版 我们在PC端用微信又多了一种方式,而且比windows桌面版本更加友好,更加方便. 我相信:对于我们绝大多数办公 ...
- Why DNS Based Global Server Load Balancing (GSLB) Doesn’t Work
Why DNS Based Global Server Load Balancing (GSLB) Doesn't Work
- Enable a SQL Server Trace Flag Globally on Linux
https://www.mssqltips.com/sql-server-tip-category/226/sql-server-on-linux// Microsoft has recently r ...
- Java使用纯真IP库获取IP对应省份和城市
原文:http://blog.csdn.net/chwshuang/article/details/78027873?locationNum=10&fps=1 Java使用纯真IP库获取IP对 ...
- struts2,action上传文件
通过servlet实现文件上传,可以用用servlet接受到request的值的话:主要是这句话 List<?> items = upload.parseRequest(request); ...
- pycharm2016序列号失效问题解决办法
1.首先修改配置文件 Linux在/etc/hosts windows的话没记错应该在C:\Windows\System32\drivers\etc\hosts 使用时需要将“0.0.0.0 acco ...
- mysql 5.7 安装手册(for linux)
1.下载和解压mysql数据库 wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.9-linux-glibc2.5-x86_6 ...
- BUPT复试专题—解析表达式(2015)
题目描述 输入一个字符串形式的表达式,该表达式中包括整数,四则运算符(+.-.*./),括号,三角函数(sin(x).cos(x).tan(x)),底数函数(lg(x).ln(x)),计算该表达式的值 ...