// 多校6 1010 HDU5802 Windows 10
// 题意:从p到q有三种操作,要么往上升只能1步,要么往下降,如果连续往下降就是2^n,
// 中途停顿或者向上,下次再降的时候从1开始。问最少次数
// 思路:
// 1.下么一直往下降,到q的下方,然后再往上升。
// 2.或者往下降到离q最近的一个点再停顿一下 然后继续往下降
// 第一种的时候,上升的时候要减去之前停顿的次数,也就是说我可以提前上升一格,不用停顿。
// 应为上升一格的话,一定是要往上一格 #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dfs(LL p,LL q,LL stop,LL ans){
if(p==q) return ans;
LL cnt=;
while(p-(<<cnt)+>q) cnt++;
if(p-(<<cnt)+==q) return ans+cnt;
LL dis=q-max(0LL,(LL)p-(<<cnt)+);
LL tem=cnt+max(0LL,dis-stop);
return min(tem+ans,dfs(p-(<<(cnt-))+,q,stop+,ans+cnt));
}
int main(){
int T;
scanf("%d",&T);
while(T--){
LL p,q;
scanf("%I64d%I64d",&p,&q);
if(p<=q){
printf("%I64d\n",q-p);
continue;
}
else{
LL ans=dfs(p,q,,);
printf("%I64d\n",ans);
}
}
return ;
}

多校6 1010 HDU5802 Windows 10 dfs的更多相关文章

  1. hdu5802 Windows 10 贪心

    Windows 10 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  2. hdu 5802 Windows 10 (dfs)

    Windows 10 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  3. hdu-5802 Windows 10(贪心)

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

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

    2016暑假多校联合---Windows 10(HDU:5802) Problem Description Long long ago, there was an old monk living on ...

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

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

  6. HDU 5802 Windows 10

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

  7. hdu 5802 Windows 10 贪贪贪

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

  8. windows 10开启bash on windows,配置sshd,部署hadoop

    1.安装Bash on Windows 这个参考官网步骤,很容易安装,https://msdn.microsoft.com/en-us/commandline/wsl/install_guide 安装 ...

  9. HDU 4685 Prince and Princess (2013多校8 1010题 二分匹配+强连通)

    Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

随机推荐

  1. Linux基础---开关机与帮助

    1.X window与文字模式的切换 通常我们也称文字模式为 终端机接口, terminal或console!Linux预设的情况下, 会提供六个Terminal来让使用者登入,切换的方式为: [Ct ...

  2. Hibernate逍遥游记-第12章 映射值类型集合-001映射set(<element>)

    1. 2. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate ...

  3. eclipse怎么集成配置JDK和Tomcat

    eclipse怎么集成配置JDK和Tomcat_电脑软件_百度经验http://jingyan.baidu.com/album/db55b609ab6a1f4ba30a2f2c.html?picind ...

  4. Intellij IDEA 创建消息驱动Bean - 接收JMS消息

    除了同步方式的调用之外,有时还需要异步调用,用来处理不需要即时处理的信息,例如短信.邮件等,这需要使用EJB中的独特组件——消息驱动Bean(Message-Driven Bean,MDB),它提供了 ...

  5. MFC多文档中opencv处理图像打开、保存

    需要在C**Doc和C**View中进行相应修改 图像打开: Doc.cpp中: BOOL CCVMFCDoc::Load(IplImage** pp, LPCTSTR csFilename) { I ...

  6. 【原创】30分钟入门 github

    很久没更新了,这篇文章重点在github的入门使用,读者可以下载github for windows shell,边看边操作,加深印象. 好了,30分钟的愉快之旅开始吧: 一.github使用的注意事 ...

  7. java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider

    Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvi ...

  8. Codeforces Round #270

    A 题意:给出一个数n,求满足a+b=n,且a+b均为合数的a,b 方法一:可以直接枚举i,n-i,判断a,n-i是否为合数 #include<iostream> #include< ...

  9. 通过AJAX与ASP.NET结合实现的仿GridView增删改查功能

    jQurey代码部分: 1.    <script type="text/javascript"> 2.            var flag = 0; 3. 4.  ...

  10. Java [Leetcode 165]Compare Version Numbers

    题目描述: Compare two version numbers version1 and version2.If version1 > version2 return 1, if versi ...