目录导航1.1矩阵及其运算(一):创建一个矩阵类1.2矩阵及其运算(二):矩阵的运算1.3矩阵及其运算(三):矩阵的转置2.1行列式(一):创建一个行列式类2.2行列式(二):全排列与逆序数2.3行列式(三):n阶行列式2.4行列式(四):上三角行列式3.1矩阵求逆(一):伴随矩阵3.2矩阵求逆(二...
分类:
其他好文 时间:
2015-07-20 16:01:10
阅读次数:
98
题意:给出n个数字[1,n],问你可以组成多少种不同的序列,其中每一个序列由几个部分组成,每个部分包含几个数字,每部分内数字无序,部分之间数字有序。每个数字最多使用一次,可以不用。思路:枚举从n个数字中选出i个数字(组合数),再枚举将这i个数字分成j个部分(第二类斯特林数),然后乘上j的全排列。 1...
分类:
其他好文 时间:
2015-07-18 17:00:43
阅读次数:
139
http://acm.hdu.edu.cn/showproblem.php?pid=1465这道题 一开始我用全排列做 妥妥的超限 1 #include "stdio.h" 2 int n,count; 3 int a[21]; 4 int equal() 5 { 6 int flag=1;...
分类:
其他好文 时间:
2015-07-17 18:13:51
阅读次数:
134
题目没什么好说的,我的方法中只求解了[0,3400)的素数,算得上是一个优化吧。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 10000000; 7 const int M = 8; 8 ...
分类:
其他好文 时间:
2015-07-16 18:15:14
阅读次数:
155
1.3 Given two strings, write a method to decide if one is a permutation of the other.这道题给定我们两个字符串,让我们判断一个是否为另一个的全排列字符串。在LeetCode中,关于排列的题有如下几道,Permutat...
分类:
其他好文 时间:
2015-07-16 09:36:18
阅读次数:
138
You are givennk-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number wa...
分类:
其他好文 时间:
2015-07-15 01:17:15
阅读次数:
244
摘自《剑指offer》 题目要求很简单,输出一串字符串的全排列,例如:输入abc 输出 abc/acb/bac/bca/cba/cab 代码我是真没怎么看明白,可能这也是递归程序比较难调试的原因吧. void Permutation(char *pstr,char *pBegin) { if (*p...
分类:
其他好文 时间:
2015-07-14 22:28:10
阅读次数:
178
全排列的递归实现虽然简单,但不容易理解。在绘制了一个树形结构图后,终于看清了里面的计算过程。但是虽然理清了过程,还是不明白为什么会这样设计。尤其是在递归调用的前后分别进行一次交换操作,感觉总是摸不着头绪。内心深处有个声音,往往让你绞尽脑汁不得其解的问题越是你的软肋。记得在高中学数学的时候,往往会因为...
分类:
其他好文 时间:
2015-07-14 19:31:17
阅读次数:
114
Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:
Triangle
P3,n=n(n+1)/2
1, 3,...
分类:
其他好文 时间:
2015-07-14 18:23:07
阅读次数:
83
题目传送门 1 /* 2 题意:将字符串分割成一个全排列 3 DFS:搜索主要在一位数和两位数的处理,用d1, d2记录个数,在不饱和的情况下,两种都试一下 4 DFS还是写不来,难道是在家里懒? 5 */ 6 #include 7 #include 8 #inc...
分类:
其他好文 时间:
2015-07-12 09:33:07
阅读次数:
272