摘要: 旅行商问题 总时间限制: 1000ms 内存限制: 65536kB 描述 某国家有n(1 using namespace std; int cities[12][12] = {}; bool visited[12] = {}; //标记去过的城市,如果去过了,则记true int n; int su 阅读全文
posted @ 2020-03-18 22:34 Allegro_VivAce 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 问题描述 把数列$(x_1,x_2,\cdots,x_n)$变换顺序为$(x_{p(1)},x_{p(2)},\cdots,x_{p(n)})$,其中$p$是$A=\{1,2,3,\cdots,n\}$的一个排列,要求只使用$O(1)$的额外空间。例如,当数列为$(10,20,30,40)$,$p$ 阅读全文
posted @ 2020-03-18 22:19 Allegro_VivAce 阅读(385) 评论(4) 推荐(0) 编辑
摘要: 开头废话 这个问题是Donald.E.Knuth在他发表的论文Mathematical Analysis of Algorithms中提到的,这里对他的算法分析过程给出了更详细的解释。 问题描述: 给定一个数组a[1,2,...,n],用尽量少的比较次数找出数组中第t大的数。(假定这n个数两两不同) 阅读全文
posted @ 2020-03-18 21:18 Allegro_VivAce 阅读(368) 评论(0) 推荐(0) 编辑