摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1166线段树,单点更新 1 #include <stdio.h> 2 3 #define lson l, m, root<<1 4 #define rson m+1, r, root<<1|1 5 6 const int maxn = 55555; 7 8 int sum[maxn<<2]; 9 10 void push_up(int root)11 {12 sum[root] = sum[root<<1] + sum[root<<1|1 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1421DPdfs记忆化搜索写的,没空间优化 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #define N 2013 5 6 int n, k, a[N], dp[N][N]; 7 8 int min(int x, int y) 9 {10 return x<y? x: y;11 }12 13 int sq(int x)14 {15 return x*x;16 }17 18 int dfs(int i, int j)19 {20 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1058DP#include <stdio.h>#define N 5848int h[N];int a[4];int p[4] = {1, 1, 1, 1};int min(){ int i, flag = 0; for(i=1; i<4; i++) { if(a[i] < a[flag]) { flag = i; } } for(i=0; i<4; i++) { if(a[i] == a[fla... 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1024DP最大m个不重叠连续子段和 1 #include <stdio.h> 2 3 #define N 1000100 4 5 int a[N], dp1[N], dp2[N]; 6 7 int max(int x, int y) 8 { 9 return x>y? x: y;10 }11 12 int main()13 {14 int i, j, n, m;15 while(~scanf("%d%d", &m, &n))16 {17 for(i=1; 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1160DP,LIS 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 struct Point 5 { 6 int x, y, num; 7 }p[1234]; 8 9 int cmp(const void *a, const void *b)10 {11 return ((struct Point *)b)->x - ((struct Point *)a)->x;12 }13 14 int n, dp[1234], pre[12 阅读全文