2012年8月24日
摘要: 题目大意:给你一系列的字符串,让你从中找寻最大子序列,反向相同也可以。思路:暴力枚举长度最小的字符串的所有情况,这里相当于剪枝。然后根据strstr(char *sz1, char *sz2)判断是否存在于其子串中。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<algorithm>usingnamespacestd;constintSIZE=101;structnode{charstr[SIZE];intlen;}a[SIZE];charsave[SIZE], 阅读全文
posted @ 2012-08-24 21:59 有间博客 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 欧拉函数筛选法练习。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>usingnamespacestd;constintSIZE=3000001;__int64phi[SIZE];voidinit(){inti,j;memset(phi,0,sizeof(phi));phi[1]=1;for(i=2;i<SIZE;i++)if(!phi[i]){for(j=i;j<SIZE;j+=i){if(!phi[j])phi[j]=j;phi[j]=phi[j]/i*(i-1);}}ret 阅读全文
posted @ 2012-08-24 19:36 有间博客 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 欧拉函数的应用,以后看到互质的数第一个就要想到欧拉函数。今天又学到了好多家伙。欧拉定理:欧拉定理表明,若n,a为正整数,且n,a互质,(a,n) = 1,则a^φ(n) ≡ 1 (mod n)费马小定理:且(a,p)=1,那么 a^(p-1) ≡1(mod p) 假如p是质数,且a,p互质,那么 a的(p-1)次方除以p的余数恒等于1。筛选法求欧拉函数,时间复杂度O(nloglogn), CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>usingn 阅读全文
posted @ 2012-08-24 17:26 有间博客 阅读(460) 评论(0) 推荐(0) 编辑
摘要: 简单模拟。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>usingnamespacestd;constintSIZE=101;intsave[SIZE];intmain(){inta,div;while(~scanf("%d%d",&a,&div),a,div){inti,first=1;memset(save,0,sizeof(save));intcnt=0;for(i=0;i<=99;i++){if((a*100+i)%div==0){save 阅读全文
posted @ 2012-08-24 17:08 有间博客 阅读(146) 评论(0) 推荐(0) 编辑