随笔分类 -  专题--暴力

摘要:题目 分析:这个题的数据范围很小,直接打印全排列去判断也能过,但是这里存在两个剪枝,第一个,如果当前的距离已经大于前面距离的最小值,则剪枝,还有一个就是如果与当前结点相连的边数大于等于前面距离的最小值,则剪枝 1 #include "iostream" 2 #include "cstdio" 3 # 阅读全文
posted @ 2017-04-13 11:12 wolf940509 阅读(104) 评论(0) 推荐(0)
摘要:回溯法是初学者学习暴力法的第一个障碍,所谓回溯就是指当把问题分成若干步骤并递归求解时,如果当前步骤没有合法选择,则函数将返回上一级递归调用,这种现象称为回溯。正是因为这个原因,递归枚举算法常被称为回溯法,应用十分普遍。 八皇后问题 1 int tot=0; 2 int c[maxn]; //c[x] 阅读全文
posted @ 2017-04-12 01:36 wolf940509 阅读(495) 评论(0) 推荐(0)
摘要:题目 分析:x>=y故1/y>=1/x,1/k-1/y<=1/y,所以可知道y<=2k,然后通过y去求解x即可 1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "vector" 5 using nam 阅读全文
posted @ 2017-04-10 09:22 wolf940509 阅读(287) 评论(0) 推荐(0)
摘要:题目 分析:水题,枚举起点和终点即可 1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "string" 5 using namespace std; 6 const int maxn=25; 7 in 阅读全文
posted @ 2017-04-09 21:07 wolf940509 阅读(116) 评论(0) 推荐(0)
摘要:题目 分析:暴力每句满足条件的打印出来即可 1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 using namespace std; 5 int n; 6 int vis[11]; 7 bool judge(int a 阅读全文
posted @ 2017-04-06 21:12 wolf940509 阅读(109) 评论(0) 推荐(0)