![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dfs
wb129945130
这个作者很懒,什么都没留下…
展开
-
计蒜课-统计三角形
给N根不同长度的木棍,求这些木棍一共能拼出多少个不同的不等边三角形。注意在拼三角形的时候一定要用上所有的N根木棍。不同的定义是至少有一条边的长度不相同;不等边的定义是三条边都不相等。输入格式:第一行为数据组数T,(1<=T<=15)。 接下来每行数据占两行,第一行为木棍的数量N(1<=N<=15) 第二行有N个正整数li(1<=li<100),表示N个木棍的长度。保证每个长度都不相同。输出格式:原创 2015-07-27 08:33:37 · 557 阅读 · 0 评论 -
UVALive 6661 Equal Sum Sets
Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesnt matter, that is, both {3, 5, 9} and {5, 9,原创 2015-07-31 20:56:20 · 397 阅读 · 0 评论 -
啊哈,算法!-----dfs3
题目描叙 迷宫由n行m列的单元格测组成(n和m都小于等于50),每个单元格要么是空地,要么是障碍物。你的任务是找到一条从迷宫起点通往同伴的最短路径。注(障碍物不能通过,也不能走到迷宫外) 代码实现#include<iostream> #include<cstdio> using namespace std;int n,m,p,q,_min=99999999; int a[51][51],book原创 2015-08-05 21:53:04 · 436 阅读 · 0 评论 -
啊哈,算法!-----dfs2
从1~9九个组成形如abc+def=ghi的式子 输出式子的总数代码实现#include<iostream> #include<cstdio> using namespace std;int a[10],book[10],total=0; void dfs(int step) { int i; if(step==10) { if(a[1]*100+a[2]*原创 2015-08-05 20:28:35 · 376 阅读 · 0 评论 -
啊哈,算法! -----dfs1
问题:输入一个数n,输出1~n的全排序。(利用深度搜索)题解:假设每个n个盒子去存储n个数字代码实现#include<cstdio> #include<iostream> using namespace std;int a[10],book[10],n; void dfs(int step) //step表示盒子的编号 { int i; if(step==n+1) {原创 2015-08-04 20:33:52 · 405 阅读 · 0 评论