hdu 5802 Windows 10

官方题解:

Windows 10

_您可能是正版Windows 10的受害者_ 直接贪心就好

比较直观的看法是使劲往下降,然后升回来

或者使劲往下降然后停顿然后再使劲往下降。。。

于是就能将问题变成一个子问题,然后dfs就好

需要注意的是由于按up键也可以打断连续向下的功效

所以应该记录停顿了几次,以后向上的时候用停顿补回来

/*by*/
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const LL N=500;
const LL INF=0x3f3f3f3f;
LL p,q;
int main()
{
    LL T;
    cin>>T;
    while(T--) {
        scanf("%lld%lld",&p,&q);
        if(p<=q) {
            printf("%lld\n",q-p);
            continue;
        }
        LL ans=INF,down=1,s=0,st=0;/*s:操作次数;st:停顿的次数*/
        while(p>=q){
            p-=down;
            down<<=1;
            s++;
            if(p<=q){
                if(q-p<=st){/*向上操作次数可以被停顿的次数代替*/
                    ans=min(ans,s+st);
                    break;
                }
                LL tmp=max(q-max(p,(LL)0),st);/*音量大于0*/
                ans=min(ans,tmp+s);
                down>>=1;
                p+=down;
                down=1;
                st++;
                s--;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}
时间: 2024-11-05 22:34:17

hdu 5802 Windows 10的相关文章

hdu 5802 Windows 10(2016 Multi-University Training Contest 6——贪心+dfs)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5802 Windows 10 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1005    Accepted Submission(s): 333 Problem Description Long long ago, there was a

hdu 5802 Windows 10 (dfs)

Windows 10 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2191    Accepted Submission(s): 665 Problem Description Long long ago, there was an old monk living on the top of a mountain. Recently,

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 Problem Description Long long ago, there was an old monk living on the top of a mountain. Recently,

2016暑假多校联合---Windows 10

2016暑假多校联合---Windows 10(HDU:5802) 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 j

Install Hyper-V on Windows 10

? Enable Hyper-V to create virtual machines on Windows 10.Hyper-V can be enabled in many ways including using the Windows 10 control panel, PowerShell (my favorite) or using the Deployment Imaging Servicing and Management tool (DISM). This documents

Windows 10 UWP程序标题栏设置

原文:Windows 10 UWP程序标题栏设置 在Windows 10程序中,以前只能用于全屏方式的Metro程序现在可以运行在窗口模式下了,并且改了个新名字,叫Windows 通用程序(Universal Windows app),简称UWP程序.新的UWP程序虽然大体上还是和以前的Metro程序差不多的,但还是引入了一点新东西的,本文这里就介绍一下它的标题栏设置的几个特性. 隐藏标题栏: 将应用界面扩展至 Titlebar 区域 CoreApplication.GetCurrentView

How to enable C development in a Windows 10 development environment VM

To enable C development in a Windows 10 development environment VM, follow these steps: Start VS in the Windows 10 development environment VM. Choose "File" -> "New" -> "Project", choose "Open Visual Studio Install

设置UWP程序自启动(Automate launching Windows 10 UWP apps)

原文:设置UWP程序自启动(Automate launching Windows 10 UWP apps) 在开发UWP程序的过程中,有时候需要设置程序的自启.本人实现的步骤如下: 1.在VS中激活Protocol (Package.appxmanifest --> Declarations --> Add Protocol),图示如下: 2.编译并发布项目(Build and Deploy) 发布之后Protocol被激活,在(控制面板 --> 程序 --> 默认程序 -->

Windows 10 KMS 手工激活

第一.安装好Win10系统,不需要安装其他激活工具.第二.是删除默认序列号,打开命令提示符(管理员),运行 slmgr.vbs -upk,可提示已卸载了序列号. slmgr /ipk W269N-WFGWX-YVC9B-4J6C9-T83GXslmgr /skms kms.xspace.inslmgr /ato KMS 的激活密钥 Windows 10 Professional       W269N-WFGWX-YVC9B-4J6C9-T83GXWindows 10 Professional