摘要: #include <stdio.h>#define abs(a) ((a)<0?-(a):(a))__int64 gcd(__int64 a,__int64 b){ return !b?a:gcd(b,a%b);}void exgcd(__int64 i,__int64 j,__int64 &a,__int64 &b){ if(!j) a=1,b=0; else exgcd(j,i%j,b,a),b-=(a*(i/j));}int main(){ __int64 x,y,n,m,l; while(scanf("%I64d %I64d %I64d %I 阅读全文
posted @ 2012-04-18 10:39 shijiwomen 阅读(333) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>#define M 1000char b[M],c[M];int a[M][M];int main(){ int i,j,n,m; while(scanf("%s%s",b+1,c+1)!=EOF) { n=strlen(b+1); m=strlen(c+1); for(i=0;i<=n;i++) a[i][0]=0; for(i=0;i<=m;i++) a[0][i]=0... 阅读全文
posted @ 2012-04-18 09:34 shijiwomen 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 刚开始做时思路过于局限,只考虑局部的递推,没有全局观导致,越推越复杂,最后看到网上答案,精髓啊#include <iostream>#include <string.h>#include <stdio.h>using namespace std;int max3(int a,int b,int c){ a = a>b?a:b; a = a>c?a:c; return a;}int max2(int a,int b){ a = a>b?a:b; return a;}int t[100001][11];int main(){ int n,T,x 阅读全文
posted @ 2012-04-18 09:24 shijiwomen 阅读(195) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int main(){ int n,a[1010],i,j,max,b[1010]; while(scanf("%d",&n),n) { for(i=1;i<=n;i++) { scanf("%d",&a[i]); b[i]=a[i]; } max=a[1]; for(i=2;i<=n;i++) { for(j=1;j<i;j++) { if(a[i]>a[j]&&b[i]<a[i]+b[j]) b[i]=a[i]+b[j]; } if(b[i] 阅读全文
posted @ 2012-04-17 17:26 shijiwomen 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 染色插入算法procedure Insert(p, l, r, a, b, c: Integer);var m: Integer;begin if Tree[p].cover <> c then begin m := (l + r) div 2; if (a = l) and (b = r) then Tree[p].cover := c else begin if Tree[p].cover >= 0 then begin Tree[p * 2].cover := Tree[p].cover; Tree[p * 2 + 1].cover := Tree[p].cover; 阅读全文
posted @ 2012-04-17 16:45 shijiwomen 阅读(357) 评论(0) 推荐(0) 编辑
摘要: 其中的标志s用的很妙,非常精髓,标记是否是纯色,单色,是否往下递归,计算单色数据#include <iostream>#include <cstdio>using namespace std;const int MAXN=2000000;int n,m,a[MAXN+5],ans;struct tree{ int l,r; int s;}trees[MAXN*2];int max(int k,int l){ return k>l?k:l;}void buildtree(int rs,int l,int r){ //printf("%d %d %d\n&q 阅读全文
posted @ 2012-04-17 15:37 shijiwomen 阅读(209) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <cstdio>using namespace std;const int MAXN=2000000;int n,m,a[MAXN+5];struct tree{ int l,r; int v;}trees[MAXN*2];int max(int k,int l){ return k>l?k:l;}void buildtree(int rs,int l,int r){ //printf("%d %d %d\n",rs,l,r); trees[rs].l=l; trees[rs].r=r; 阅读全文
posted @ 2012-04-17 11:50 shijiwomen 阅读(194) 评论(0) 推荐(0) 编辑
摘要: //#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>//using namespace std;const int MAXN=10000;struct ele{ int inte; int weit; int num;}eles[MAXN];int cmp(const void *a,const void *b){ struct ele t=*(struct ele *)a; struct ele l=*(struct ele *)b; if(t 阅读全文
posted @ 2012-04-15 19:49 shijiwomen 阅读(173) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int main(){ int m,k; int t,s=0; scanf("%d",&t); while(t--) { scanf("%d%d",&m,&k); printf("Case #%d: %.8lf\n",++s,(double)1/(k+k*m+1)); } return 0;} 概率题 要分清合法和不和法的边界,再去求这题很明显,如果这个序列合法,则他的任意一个序列的循环移动都是不合法的 阅读全文
posted @ 2012-04-14 10:59 shijiwomen 阅读(241) 评论(0) 推荐(0) 编辑
摘要: n个数,+、-、.号等于0的等式 输出等式和总过的等式#include <iostream>#include <cstdio>#include <string.h>using namespace std;const int MAXN=20;const int MAXM=16;char str[MAXM],opt[MAXN][MAXM];int n,cnt;void dfs(int deep,int num,int pre){ int now,k; if(deep==n) { str[n]='\0'; if(num==0) { if(cnt&l 阅读全文
posted @ 2012-04-13 23:28 shijiwomen 阅读(319) 评论(0) 推荐(0) 编辑