摘要:
http://codeforces.com/problemset/problem/39/A贪心 按照常数大小从小到大排序, 结果一个一个计算上来, 不影响结果正确性。View Code #include <iostream>#include <cstdio>#include <vector>#include <cmath>#include <set>#include <map>#include <queue>#include <fstream>#include <string>#incl 阅读全文
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=524LCS 细节View Code #include <iostream>#include <cstdio>#include <vector>#include <cmath>#include <set>#include <map>#include <queue>#include <string>#include <cstring>#include <algorit 阅读全文
摘要:
View Code /*==================================================*\| 最长有序子序列(递增/递减/非递增/非递减)\*==================================================*/const int N = 1001;int a[N], f[N], d[N]; // d[i]用于记录a[0...i]的最大长度int bsearch(const int *f, int size, const int &a) { int l=0, r=size-1; while( l <= r ) 阅读全文
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3523ZOJ 求使无序的序列变有序的最小花费, LIS, struct 初始化需要特别注意View Code #include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>int f_min(int x,int y) {if(x<y)return x;else return y;}int 阅读全文
摘要:
Merge sortView Code #include <iostream>#include <cstdio>#include <vector>#include <cstring>#include <algorithm>int f_min(int x,int y) {if(x<y)return x; else return y;}int f_max(int x,int y) {if(x<y)return y; else return x;}//double f_min(double x,double y) {if(x&l 阅读全文
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2901一般DP复杂度 O(L*N^2), 分段计算 O(lgL*N*N)View Code #include <iostream>#include <cstdio>#include <vector>#include <queue>#include <map>#include <string>#include <cstring>#include <algorithm>int f_ 阅读全文
摘要:
链接:LIS -> 矩形造塔 阅读全文
摘要:
http://www.cplusplus.com/reference/cctype/isalnumView Code /* isalnum example *//*Checks whether c is either a decimal digit or an uppercase or lowercase letter.*/#include <stdio.h>#include <cctype>int main (){ int i; char str[]="c3Po..."; i=0; while (isalnum(str[i])) i++; prin 阅读全文
摘要:
http://www.cplusplus.com/reference/cassert/View Code /* assert example */#include <stdio.h> /* printf */#include <assert.h> /* assert */void print_number(int* myInt) { assert (myInt!=NULL); printf ("%d\n",*myInt);}int main (){ int a=10; int * b = NULL; int * c = NULL; b=&a; 阅读全文
摘要:
http://www.codeforces.com/contest/283/problem/AView Code #include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MM = 222222;#define debug puts("wrong")typedef __int64 int64;#define lson rt<<1#define rson rt<& 阅读全文