2015 多校第三场 Solve this interesting problem
来源:互联网 发布:淘宝sns是什么 编辑:程序博客网 时间:2024/06/05 08:45
任意给定一个区间,求包含此区间的线段数的最小根节点N,不存在输出-1
注意各种剪枝
# include <stdio.h># include <string.h># include <algorithm>using namespace std;const long long INF=1e18;long long ans;void dfs (long long l,long long r){ // printf("%d %d\n",l,r); if(r>=ans) return ; if(l<0) return ; if(l==0) { ans=r; return ; } if(r-l+1>l) return ; dfs(2*l-r-1,r); dfs(2*l-r-2,r); dfs(l,2*r-l); dfs(l,2*r-l+1);}int main (){ long long r,l; while(scanf("%I64d%I64d",&l,&r)!=EOF) { ans=INF; dfs(l,r); if(ans==INF) printf("-1\n"); else printf("%I64d\n",ans); } return 0;}
0 0
- 2015 多校第三场 Solve this interesting problem
- hdu 5323 Solve this interesting problem(15多校第三场1008)(暴力)
- 多校第三场 1006 hdu 5323 Solve this interesting problem(dfs)
- hdu多校第三场 Solve this interesting problem (5323 线段树模拟 + DFS)
- Solve this interesting problem
- 2015多校Solve this interesting problem
- H - Solve this interesting problem
- HDU5323.Solve this interesting problem
- HDU 5323 Solve this interesting problem
- HDU 5323 SOLVE THIS INTERESTING PROBLEM 爆搜
- 【搜索】 HDU 5323 Solve this interesting problem
- HDU 5323 Solve this interesting problem(暴搜)
- HDU5323 Solve this interesting problem 暴力DFS
- hdu 5323 Solve this interesting problem 【DFS】
- 多校赛3- Solve this interesting problem
- hdu 5323 Solve this interesting problem
- HDU 5323 Solve this interesting problem(DFS)
- HDU 5323Solve this interesting problem(DFS)
- 删除JDK报错:Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
- 小米等手机不能显示windowmanager的问题和webview加载https网址报错的问题
- Android 异常 android.os.NetworkOnMainThreadException
- openfire学习1
- sublime text安装插件出现问题
- 2015 多校第三场 Solve this interesting problem
- ArrayList的使用方法
- 图论浅析--最小生成树之Prim
- iOS开发——网络编程OC篇&GCDAsyncSocket编程
- 把一串字符串大写转成小写
- MyBatis Generator generatorConfig.xml配置详解
- 我的游戏开发笔记(一):完善并把u3d自带的ThirdPersonController.js改成cs版本
- HTTP1.1中CHUNKED编码解析 http://blog.csdn.net/zhangboyj/article/details/6236780
- 游戏架构脚本该如何来写