随笔分类 -  模板

摘要:#include <cstdio>#include <algorithm>#include <cmath>#include <queue>#include <iostream>#include <cstring>using namespace std;#define DIGIT 4 //四位隔开,即 阅读全文
posted @ 2016-07-20 12:40 weeping 阅读(351) 评论(0) 推荐(0)
摘要:#include using namespace std; int dp[10000][10000]; int lcs(string str,int n){ int tmp; memset(dp,0,sizeof(dp)); for(int i=0; i>n; while(n--) { cin>>s; int x=lcs... 阅读全文
posted @ 2016-07-17 23:30 weeping 阅读(173) 评论(0) 推荐(0)
摘要:poj3259 Wormholes 阅读全文
posted @ 2016-07-16 11:59 weeping 阅读(229) 评论(0) 推荐(0)
摘要:#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include ... 阅读全文
posted @ 2016-07-15 16:08 weeping 阅读(184) 评论(0) 推荐(0)
摘要:并查集 阅读全文
posted @ 2016-07-13 23:46 weeping 阅读(112) 评论(0) 推荐(0)
摘要:int mp[505][505],vis[505] int prime(int n) { int lowcost[505],sum=0; for(int i=1;ilowcost[k]) mi=lowcost[k],j=k; vis[j]=1; sum+=lowcost[j]; for(int k=1;kmp... 阅读全文
posted @ 2016-07-13 22:44 weeping 阅读(261) 评论(0) 推荐(0)
摘要:转自:yinthewind的博客 这两天看到了线性时间筛选素数,觉得它的扩展很神奇= = 先来基本的 #define N 10000000int prime[N],p;bool iscomp[N+1];void primetable(){ for(int i=2;i<=N;i++) { if(isc 阅读全文
posted @ 2016-07-13 09:26 weeping 阅读(164) 评论(0) 推荐(0)
摘要:解出的是最小正整数解 阅读全文
posted @ 2016-06-01 22:59 weeping 阅读(331) 评论(0) 推荐(0)
摘要:int c[2*K]; void add(int x,int v) { when(x0) { ret+=c[x]; x-=x&(-x); } return ret; } 阅读全文
posted @ 2016-05-11 22:05 weeping 阅读(136) 评论(2) 推荐(0)
摘要:记得有个小地方打错变量名了,要用的话自己改下就好 阅读全文
posted @ 2016-05-11 22:00 weeping 阅读(165) 评论(0) 推荐(0)
摘要:1 void init(long long n,long long m) 2 { 3 long long i,j; 4 memset(c,0,sizeof(c)); 5 for(i=0;i<=m;i++) 6 c[0][i]=c[1][i]=1; 7 for(i=0;i<=m;i++) 8 c[i][i]=1; 9 ... 阅读全文
posted @ 2016-04-28 17:34 weeping 阅读(221) 评论(0) 推荐(0)
摘要:线段树:简单的说就是把【1,n】的区间二分,【1,(1+n)/2】左子树,【(1+n)/2+1,n】右子树 就这样一直分下去,直到都是【x,x】这样的区间。这样就构成了一颗树了^-^ 有这样一棵树,我们就可以在节点中储存区间的和啊,区间内的最大值啊,最小值等等。。这就是线段树的附加信息了,也是题目中 阅读全文
posted @ 2016-04-23 00:18 weeping 阅读(211) 评论(0) 推荐(0)