hdu 5323 Solve this interesting problem(dfs)
来源:互联网 发布:天津会员卡软件 编辑:程序博客网 时间:2024/04/28 00:31
题目链接:hdu 5323 Solve this interesting problem
逆向思维,每次向左或向右翻倍,知道左端点为0时,即恰好满足的情况,处理处所有情况去取最小值。
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const ll inf = 0x3f3f3f3f;ll L, R, N;void dfs(ll l, ll r) {//printf("%lld %lld\n", l, r);if (l <= 0 || r >= 2 * R) {if (l == 0)N = min(N, r);return;}int k = r - l + 1;if (k > l)return;dfs(l - k, r);dfs(l - k - 1, r);dfs(l, r + k);if (k > 1)dfs(l, r + k - 1);}int main () {while (scanf("%lld%lld", &L, &R) == 2) {N = inf;dfs(L, R);printf("%lld\n", N == inf ? -1 : N);}return 0;}
0 0
- hdu 5323 Solve this interesting problem 【DFS】
- HDU 5323 Solve this interesting problem(DFS)
- HDU 5323Solve this interesting problem(DFS)
- Hdu 5323 Solve this interesting problem【Dfs】
- hdu 5323 Solve this interesting problem(dfs)
- HDU 5323 Solve this interesting problem(DFS)
- hdu 5323 Solve this interesting problem dfs搜索
- hdu 5323 Solve this interesting problem dfs 搜索
- HDU 5323 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(暴搜)
- hdu 5323 Solve this interesting problem
- Hdu 5323 Solve this interesting problem(搜索)
- 多校第三场 1006 hdu 5323 Solve this interesting problem(dfs)
- hdu多校第三场 Solve this interesting problem (5323 线段树模拟 + DFS)
- HDU 5323(2015多校3)-Solve this interesting problem(dfs+剪枝)
- HDU 5324 Boring Class【cdq分治】
- iOS前期OC训练OC_10Block
- java内在模型与多线程关系
- Cocos2d-JS项目之三:使用合图
- 归并排序和快速排序的比较
- hdu 5323 Solve this interesting problem(dfs)
- hdu1873~看病要排队~
- Android Studio导入开源类库
- Contains Duplicate
- 杭电 2025 查找最大元素
- 最短路
- hdoj2067 小兔的棋盘【dp+打表】or卡特兰数
- poj-1753 Flip Game
- XML文件格式语法及DTD (20 http://www.cnblogs.com/cy568searchx/archive/2013/02/26/2933815.html