HDU5323.Solve this interesting problem
来源:互联网 发布:python array split 编辑:程序博客网 时间:2024/05/18 02:22
首先如果给出[L,R],那么它一定是由[2*L-R-1,R]或者[2*L-R-2,R]或者
[L,2*R-L]或者[L,2*R-L+1]变化而来
其次考虑他的剪枝,设len=R-L+1,如果L
#include <map>#include <set>#include <stack>#include <queue>#include <cmath>#include <ctime>#include <vector>#include <cstdio>#include <cctype>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>using namespace std;#define INF 0x3f3f3f3f#define inf -0x3f3f3f3f#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define mem0(a) memset(a,0,sizeof(a))#define mem1(a) memset(a,-1,sizeof(a))#define mem(a, b) memset(a, b, sizeof(a))typedef long long ll;const int maxn=100000+100;int ans;void dfs(int L,int R,int cnt){ if(cnt>=13) return ; if(L<0) return ; if(L==0){ ans=min(ans,R); return ; } int len=R-L+1; if(L<len) return ; if(R>L){ dfs(L,2*R-L,cnt+1); } dfs(L,2*R-L+1,cnt+1); dfs(2*L-R-2,R,cnt+1); dfs(2*L-R-1,R,cnt+1);}int main(){ int L,R; while(scanf("%d%d",&L,&R)!=EOF){ ans=INF; dfs(L,R,0); printf("%d\n",ans==INF? -1:ans); } return 0;}
0 0
- HDU5323.Solve this interesting problem
- HDU5323 Solve this interesting problem 暴力DFS
- 解题报告 之 HDU5323 Solve this interesting problem
- hdu5323(2015多校3)--Solve this interesting problem(万万没想到,,,)
- Solve this interesting problem
- H - 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 【DFS】
- 多校赛3- Solve this interesting problem
- 2015多校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】
- hdu 5323 Solve this interesting problem(dfs)
- Redhat安装gem包报错“no such file to load — zlib”以及ruby的openssl扩展等错误的修正
- [尺取法] poj3320 Jessica's Reading Problem
- Android 存储学习之保存系统短信到SD卡
- HTML5 文件上传示例
- Codeforces 547B Mike and Feet(单调栈)
- HDU5323.Solve this interesting problem
- Linux搭建wordpress
- 斐波那契数列
- android与javascript的交互
- Numpy中矩阵对象(matrix)
- 广播接收器动态注册
- ucp2p 库:二、编译使用
- 茄子快传和腾讯全民Wifi配合使用
- 理解python的slice