摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1686KMP算法,今天又到了好晚,不过今天总的来说收获还是很大的,做了好几道KMP的题目,呵呵,心情也还不错,这是一道纯模版题,感觉很简单,就是去b中找a的个数,当j=m的时候说明一个字符串匹配成功,然后求输出个数即可。。。#include <stdio.h>#include <string.h>#include <stdlib.h>int next[1000000],m,n;char a[1000000],b[1000000];void getnext(){ int i= 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2028深夜十二点水的题,第一次wa,不过后来看看很简单,gcd求最大公约数,然后每次求出最小公倍数。。。最后知道用该数除以最大公约数再乘以本身就可以了#include <stdio.h>#include <string.h>#include <stdlib.h>int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int main(){ int n,a,b,k; while(scanf("%d",&n)! 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2029这是一道回文串,以前我老是用for循环,不过今天试了试while觉得还挺好用的,呵呵,果断、一a了 。。好开心啊 ,今天有个好的开始不错哦!回文就是前面和后面一直匹配。。。若有不同的就跳出并且输出no,若一直到最后都没有不同就输出yes#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int n,m; char a[10002]; scanf("%d",& 阅读全文