
搜索
azheng51714
欢迎加入 老生畅坛 微信公众号
展开
-
hdu 4334
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4334题意:题意:给定五个集合,从五个集合中分别取出5个数,如果存在满足a1 + a2 + a3 + a4 +a5 == 0 输出yes,否则no; 集合的大小小于200 ai的取值为 [-10^15, 1 0^15]解法:If we have two sorted l转载 2012-08-04 11:40:30 · 692 阅读 · 0 评论 -
hdu 3274 简单 dfs
#include#include#include#include#include#include#includeusing namespace std;const int maxn=2001;int n,m,root,sum,NE=0,vis[maxn],head[maxn];struct node{ int u,v,w,next;} Edge[maxn];voi原创 2013-01-02 18:52:05 · 692 阅读 · 0 评论 -
hdu 2660 简单 dfs
#includeint t,n,k,weight,Max,vis[22];struct node{ int p,w;} p[22];void dfs(int wei,int val,int indx,int sum){ if(sum==k||wei==weight) { if(Max<val) { Max=原创 2012-11-07 17:51:14 · 912 阅读 · 0 评论 -
poj 1315 经典的dfs
#include#include//经典的dfs//题目描述,在给定的一副图中行列不能同时出现子,除非有墙隔开//问最大可以放的子数//典型的dfs,怎么搜呢,通常都是以行或列为一定来搜,一行一行或一列一列来搜,//然后进位,在找到一个合法点后对其进行检查行列是否有子,墙的情况也要考虑//然后有两种选择,落子或着不落子,这么搜,搜完还有恢复值#include#includeus原创 2012-11-07 17:33:23 · 948 阅读 · 1 评论 -
poj 2907 dfs
#include#include///题意:Karel在起始位置处,有n个位置有beepers,///现在Karel要从起始位置出发将这n个beepers拿到,///然后再回到起始位置,求这条路径的最小值.直接DFS求解.#include#include#includeusing namespace std;int t,n,m,vis[402],x[402],y[402],ans原创 2012-11-07 16:10:17 · 502 阅读 · 0 评论 -
poj 3411 dfs
/*题目:http://poj.org/problem?id=3411简单dfs:有n座城市和m(1<=n,m<=10)条路。现在要从城市1到城市n。有些路是要收费的,从a城市到b城市,如果之前到过c城市,那么只要付P的钱,如果没有去过就付R的钱。求的是最少要花多少钱。注意:路径是有向的。分析: 因最多有10个城市,那么我们必须防范出现环自转的现在,显然3个城市可以出现原创 2012-10-28 14:10:33 · 869 阅读 · 1 评论 -
poj 3338 dfs
#includeusing namespace std;//简单的dfs //给定一切切割,求封闭区间个数//对于每一割,用2的指数来表示,重叠则累加 这表示的是状态,之后用类似种子天填充的方法统计即可 int w,h,n;__int64 num[61];__int64 map[25][25];__int64 temp,c;int s[25][25];int原创 2012-10-28 14:22:40 · 578 阅读 · 0 评论 -
hdu 3345 bfs
#include #include #include using namespace std;const int M = 105;int n, m, mv;char mp[M][M], ans[M][M];int flg[M][M];int s[2];int dir[4][2] = {-1,0, 0,1, 1,0, 0,-1};struct no原创 2012-11-03 09:39:22 · 492 阅读 · 0 评论 -
ural 1005 dp dfs or 0 1背包
就是说不到20堆石头。分成2大堆。。让他们绝对值最小。。#include#include#includeusing namespace std;int w[22],n,sum[22],ans,ave;void dfs(int idx,int num){ if(num>ave)return; if(idx<=0)return; if(sum[原创 2012-11-04 14:25:00 · 566 阅读 · 0 评论 -
poj 3172 dfs
//题意:给定的n个数中,选出任意个数,使得所有的数相加之和不超过c,但得到的值最大#include#include#include#includeusing namespace std;const int maxn=1002;int n,m,res;__int64 val[maxn],num[maxn];void dfs(int idx,__int64 s原创 2012-11-03 14:46:58 · 662 阅读 · 0 评论 -
poj 2922 dfs
//求(1,1)到(n,n)的一条路径。这条路径的最大值和最小值差最小//2分+dfs//首先枚举差值,确定这次枚举的最小的最小值,因为从1,1开始且差值确定,故下界也可确定//然后枚举从下界到1,1的高度,进行dfs即可#include#include#include#includeusing namespace std;const int maxn=202;原创 2012-10-29 15:21:30 · 635 阅读 · 0 评论 -
poj 3909 简单 搜索
Lucky numbersTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 510 Accepted: 172DescriptionJohn has recently arrived in Bucharest for the South Eastern原创 2012-09-18 10:25:32 · 1237 阅读 · 0 评论 -
hdu 4282 爆搜
题意:问有多少中情况满足 X^Z + Y^Z + XYZ = K;(1=2,k解法:#include#include#include#includeusing namespace std;__int64 k;__int64 qpow(int a,int b){ __int64 res=1,d=a; while(b) { if(b&1)原创 2012-09-13 15:40:31 · 536 阅读 · 0 评论 -
hdu 4277 爆搜 set 去重
题目:给出n条边,每条边有一定的长度,现在要用所有的边围成三角形,问能够围成多少个不同的三角形(三边至少有一边不等)。#include#include#include#includeusing namespace std;int n,t,edge[17];int ans,sum;set >s;int min(int a,int b){ return a<b?a:b原创 2012-09-13 19:20:01 · 436 阅读 · 0 评论 -
poj 2790 dfs
#include#includeusing namespace std;//dfs//给定一个n*m矩阵0-1矩阵,每行代表1个人,每列代表一个事件,这个矩阵代表了每个人是否参加了某个事件//找一个事件排列,使得每个人参加事件连续 枚举+回溯const int maxn=400;int n,m,len;char map[maxn][maxn];int sum[maxn];//su转载 2012-09-27 14:38:07 · 960 阅读 · 0 评论 -
poj 2303 简单dfs
#include#include///貌似是一个纯暴力的题目,给出2*n 个物品,将其连续套进两个循环套///符合题意的情况是 相邻两个布娃娃 h,d,w 满足 h-2w>=h1,d-2w>=d1;#include#includeusing namespace std;const int maxn=102;int n,flag,p[3][maxn],res[3][maxn];st原创 2012-09-27 09:53:51 · 772 阅读 · 0 评论 -
poj 1599 简单 dfs
题意:给你C个小组(C=S)。要将这S个数值分配给C个小组,每小组最多分配两个数值。求最优的分配方式,使得下面 IMBALANCE 的值最小。其中AM = 所有数值之和 / C; CMi = 第i小组的数值之和;#include#include#include#include#include#includeusing namespace std;const int max原创 2012-09-26 20:49:41 · 496 阅读 · 0 评论 -
UVA 10318 简单dfs
#include#include#includeusing namespace std;const int MAXN= 6;const int inf=1int n, m,cas=1;bool pat[3][3];int path[MAXN*MAXN], mat[MAXN], mm;void read(){ memset(mat,0, sizeo原创 2013-04-22 11:23:42 · 639 阅读 · 0 评论