hdu3336
来源:互联网 发布:多管火箭炮升级数据 编辑:程序博客网 时间:2024/05/28 23:20
http://acm.hdu.edu.cn/showproblem.php?pid=3336
#include <iostream>#include <cstdio>#include <cstring>using namespace std;int next[200005];char str[200005];void get_next(char *str,int n){ int i,j; next[0]=-1; i=0;j=-1; while(i<n) { if(j==-1||str[i]==str[j]) i++,j++,next[i]=j; else j=next[j]; }}int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); scanf("%s",str); get_next(str,n); int i,s=0; for(i=1;i<=n;i++) { if(next[i]!=0) //next[i]表示前缀等于后缀的最大长度,需仔细理解kmp算法 s++; if(s>10007) s=s%10007; } s=s+n; s=s%10007; printf("%d\n",s); } return 0;}
- hdu3336
- hdu3336
- hdu3336
- hdu3336
- hdu3336(KMP)
- HDU3336-KMP
- hdu3336 KMP
- hdu3336(kmp)
- HDU3336(KMP)
- hdu3336 KMP
- hdu3336 Count the string
- hdu3336 Count the string
- HDU3336:Count the string
- hdu3336-Count the string
- HDU3336------KMP+DP
- hdu3336之KMP应用
- hdu3336 Count the string
- hdu3336(KMP+DP)
- PMP项目管理之核心:项目经理角色定位
- 继承中的构造方法
- matlab中将视频流转换成图片
- 如何在KVM中管理存储池
- fix:error: stray '\357' in program
- hdu3336
- GIS在商业中的应用
- 【hdu3555】【数位DP】Bomb
- 谁来签署项目的完工报告
- 字符串处理:0xABCD,如果是大端规则,在内存中CD存在高地址位,AB存在低位,printf的时候先打CD,再打AB
- 初学者编程练习2
- [转载]The TTY demystified
- php出错Warning: Cannot modify header information - headers already sent by (output started at
- shell脚本--建立办公室名录