2015多校Solve this interesting problem
来源:互联网 发布:知鱼之乐 编辑:程序博客网 时间:2024/05/16 08:13
题目意思:给一个区间[l,r],问你在二叉树中能不能找到这个区间[0,n],使得二叉树中有[l,r]这个节点。如果能输出n的最小值,不能输出-1。
分析:题目用dfs做。对于每一个[l,r],往上一个根节点搜索。对于[l,r]的姊妹节点有4种,左边两种[2*l-r-1,l-1]或者[2*l-r-2,l-1],右边两种[r+1,2*r-l+1],[r+1,2*r-l],因此,根节点也有4种。一直到l==0。
注意边界,左边是l<0;右边是r-l>l-1;
0 0
- 2015多校Solve this interesting problem
- Solve this interesting problem
- H - Solve this interesting problem
- HDU5323.Solve this interesting problem
- 2015 多校第三场 Solve this interesting problem
- hdu5323(2015多校3)--Solve this interesting problem(万万没想到,,,)
- HDU 5323(2015多校3)-Solve this interesting problem(dfs+剪枝)
- 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)
- Hdu 5323 Solve this interesting problem【Dfs】
- hdoj 5240 Exam 【模拟】
- Redis源码分析(二十五)--- zmalloc内存分配实现
- 《关于多代理系统的研究》01
- linux下一个网卡配置多个ip【虚拟ip】
- tomcat管理员密码设置
- 2015多校Solve this interesting problem
- HDU 3669 Cross the Wall (斜率优化DP)
- redis内存管理代码注释
- 在eclipse中打开文件所在的目录
- oracle数据库用户加锁和解锁
- android 截图保存位置不在已选择的“SD卡”中
- LInux last命令详解
- 剖析Disruptor:为什么会这么快?(三)揭秘内存屏障
- android 截图保存位置不在已选择的“SD卡”中