上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 71 下一页
摘要: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2080最长公共子序列状态方程if (ci==cj)dp[i][j] = dp[i-1][j-1]+1;elsedp[i][j] = max{dp[i-1][j],dp[i][j-1]};View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 using namespace std; 5 int main() 6 { 7 阅读全文
posted @ 2012-08-10 14:52 _雨 阅读(244) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1215打表 从小到N/2 筛能把自己整除的数#include <iostream>#include<cstdio>#include<string.h>#define N 500001using namespace std;__int64 s[N+10];int main(){ int i,j,k,n,m; for(i = 1 ; i <= N/2 ; i++) { for(j=i+i ; j< N ; j+=i) s[j]+=i; } scanf("% 阅读全文
posted @ 2012-08-10 09:08 _雨 阅读(148) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1698View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 using namespace std; 5 #define max 100000 6 int s[max*4],te[max*4]; 7 void pushup(int w) 8 { 9 s[w] = s[2*w]+s[2*w+1];10 }11 void pushdown(int w,int m)12 {13 if(t 阅读全文
posted @ 2012-08-09 23:40 _雨 阅读(171) 评论(0) 推荐(0) 编辑
摘要: http://acm.sdut.edu.cn/bbs/read.php?tid=5651。。本来只会向上更新 现在学习了如何向下更新 延迟标记法。。。使复杂度降低View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 using namespace std; 5 #define max 100000 6 __int64 s[max*4],te[max*4]; 7 void pushup(int w) 8 { 9 s[w] = s[2*w]+s[2*w+1];10 }1 阅读全文
posted @ 2012-08-09 23:09 _雨 阅读(155) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1754依次比较左右子节点 父节点存最大值View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #define MAX 200000 5 using namespace std; 6 int s[MAX*4],a; 7 void push(int w) 8 { 9 if(s[2*w]>s[2*w+1])10 s[w] = s[2*w];11 else12 s[w... 阅读全文
posted @ 2012-08-09 11:55 _雨 阅读(170) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4217开一个数组标记这个数是否被拿走 s[w]为区间和 当求第K小的数的时候 让他与s[w]的左右子树比较 看在哪个区间中 依次找下去 总会找到一个s[]与他相等 所对应的区间就是那个应该被拿走的值View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #define MAX 262144 5 using namespace std; 6 int to[4*MAX]; 7 __int 阅读全文
posted @ 2012-08-09 10:20 _雨 阅读(192) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2528线段树加离散化 搜了好多资料 WA了一下午终于把这题做出来了 看讨论上说这题数据有问题 这种离散化严格来说是不对的 但是这题却可以水过去 由于刚接触 就不去探索很精确的离散化的方法了 先把普通的离散化了解下就好代码View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #include<algorithm> 5 using namespace std; 6 #define N 20000 7 st 阅读全文
posted @ 2012-08-08 16:25 _雨 阅读(174) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3259看了好久才知道那个虫洞 是可以把人带回去 而且时间也会回到过去 判断是否有负权回路 spfa看是否有一个点进入队列等于n次bell-fordView Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #include<queue> 5 #define INF 0x3f3f3f 6 using namespace std; 7 struct node 8 { 9 int u,v,t;10 }q[5000 阅读全文
posted @ 2012-08-08 14:25 _雨 阅读(213) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1125题意很难懂 一个人可以同时向多个人传递信息 找出每个人向所有人传递完信息后的最大值 再找出这些最大值中的最小值 就是结果View Code 1 #include <iostream> 2 #include<string.h> 3 #include<cstdio> 4 #define INF 0x3f3f3f 5 using namespace std; 6 int w[101][101]; 7 int main() 8 { 9 int i,j,k,n,m,t,v,w1,x;10 while(scan 阅读全文
posted @ 2012-08-08 14:21 _雨 阅读(208) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1789模板题 题意是一个字符串跟一个字符不同的字符串有多少 这个数量就相当于权值 连起来最小View Code 1 #include <iostream> 2 #include<algorithm> 3 #include<string.h> 4 #include<cstdio> 5 #define INF 0x3f3f3f3f 6 using namespace std; 7 char c[2001][10]; 8 int w[2001][2001],vis[2001],low[2001],s 阅读全文
posted @ 2012-08-06 20:04 _雨 阅读(178) 评论(0) 推荐(0) 编辑
上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 71 下一页