转自http://www.cnblogs.com/gaojun/archive/2010/09/11/1824016.htmlC++中string是标准库中一种容器,相当于保存元素类型为char的vector容器(自己理解),这个类提供了相当丰富的函数来完成对字符串操作,以及与C风格字符串之间转换,下面是对string一些总结<引用> 一,C语言的字符串在C语言里,对字符串的处理一项都是一件比较痛苦的事情,因为通常在实现字符串的操作的时候都会用到最不容易驾驭的类型——指针。比如下面这个例子://example 1:char str[12] = "Hello";c Read More
posted @ 2012-10-07 17:18 sidereal Views(282) Comments(0) Diggs(0)
1 #include <stdio.h> 2 #include <string.h> 3 4 char preorder[30]; 5 char inorder[30]; 6 char tree[1000000]; //tree index starts from 1 //树的深度问题,2^h数组大小,选得太小会AW 7 char postorder[30]; 8 int postindex; 9 int search(char ch,char array[],int start,int end)10 {11 for(int i=start;i<=end;i++) Read More
posted @ 2012-10-07 16:26 sidereal Views(190) Comments(0) Diggs(0)
sigular value decomposition$A\epsilon R^{m*n}$, A can be decomposed into $A=UDV^T$, where $U\epsilon R^{m*n}, D\epsilon R^{n*n}, V\epsilon R^{n*n}$$D=diagonal[\sigma_i], \sigma_i=sigular value of A$; $U$'s columns are Eigenvectors of $AA^T$; $V$'s columns are Eigenvectors of $A^TA$compute us Read More
posted @ 2012-10-07 11:31 sidereal Views(173) Comments(0) Diggs(0)
注意corridor只有200个,第n个corridor对应room 2n-1和2n 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 5 using namespace std; 6 int corridor[201]; 7 bool compare(int a,int b) 8 { 9 return a>b;10 }11 int main()12 {13 int cases;14 int n;15 int from,to;16 int start,end;17 . Read More
posted @ 2012-10-06 12:01 sidereal Views(140) Comments(0) Diggs(0)
求出素数表之后暴力搜索 1 #include <stdio.h> 2 #include <string.h> 3 int prime[10000]; 4 bool number[10001]; 5 int constructPrime(int n) 6 { 7 int i,j; 8 int pc=0; 9 memset(number,false,sizeof(number));10 for(i=2;i<=n;i++)11 if(!number[i])12 {13 prime[pc++]=i;14 ... Read More
posted @ 2012-10-06 10:20 sidereal Views(133) Comments(0) Diggs(0)
如果n是素数,则2n,3n,4n....都是合数1 void GenPrimes (int n){2 int i , j , k; pc = 0;3 memset (mk , false , n +1);4 for(i=2; i <=n; i++)5 if (! mk[i]){6 primes [pc ++] = i;7 for(j=i+i; j <=n; j+=i) mk[j] = true ;8 }9 } Read More
posted @ 2012-10-06 09:35 sidereal Views(104) Comments(0) Diggs(0)
测试数据没有问题,但是不知道为什么老得到Wrong Answer 1 #include <stdio.h> 2 #include <string.h> 3 #define MAXLEN 1000 4 struct decimal 5 { 6 int num[MAXLEN]; 7 int len; 8 int frac; 9 }; 10 11 void Product(decimal d1, decimal d2,decimal& d3) 12 { 13 int i,j; //i points to d1,j points to d2... Read More
posted @ 2012-10-03 18:13 sidereal Views(278) Comments(0) Diggs(0)
Optimal margin classifier has constraint: $y^{(i)}(w^Tx^{(i)}+b) >= 1$L1 regularization form has constraint: $y^{(i)}(w^Tx^{(i)}+b) >= 1- \zeta_i$These constraints are the condition of not causing training error.It means that when these constraints are satiesfied, there wouldn't be an erro Read More
posted @ 2012-10-02 23:17 sidereal Views(139) Comments(0) Diggs(0)
feature mapping $\phi : R^n \rightarrow R^t$replace $x^{(i)}$ with $\phi(x^{(i)})$since $X=[x^{(i)T}] \epsilon R^{m*1}$, $\phi = [\phi(x^{(i)T})] \epsilon R^{m*1}$$K_{ij}=\phi(x^{(i)})^T\phi(x^{(j)}) \epsilon R^{m*m} = \phi \phi^T \epsilon R^{m*m}$ Read More
posted @ 2012-10-02 10:42 sidereal Views(141) Comments(0) Diggs(0)
Math operator$\nabla$ is \nabla$\partial$ is \partialdifferential use d$\sum$ is \sum$\sqrt[n]{expression}$ is \sqrt[n]{expression}fraction is \frac{numerator}{denomenator}Greek Alphabet$\alpha$ is \alpha$\beta$ is \beta$\epsilon$ is \epsilon$\theta$ is \theta$\zeta$ is \zeta Read More
posted @ 2012-10-01 16:28 sidereal Views(95) Comments(0) Diggs(0)