http://acm.hdu.edu.cn/showproblem.php?pid=3336
来源:互联网 发布:人工智能利大于弊 编辑:程序博客网 时间:2024/05/01 06:11
题目大意:
所有前缀在母串中出现的次数之和。
#include<stdio.h>#define N 200009int next[N];int get_next(int len ,char *p){ int i=0,j=-1,sum=0; next[i]=j; while(i<len){ if(j==-1||p[i]==p[j]){ i++; j++; next[i]=j; }else{ j=next[j]; } } for(i=1;i<=len;i++) if(next[i]>0) ++sum; return sum+len;}int main(){ int t,n; char buff[N]; scanf("%d",&t); getchar(); while(t--){ scanf("%d",&n); getchar(); gets(buff); printf("%d\n",get_next(n,buff)%10007); }}
0 0
- http://acm.hdu.edu.cn/showproblem.php?pid=3336
- http://acm.hdu.edu.cn/showproblem.php?pid=1005
- http://acm.hdu.edu.cn/showproblem.php?pid=1333
- http://acm.hdu.edu.cn/showproblem.php?pid=2710
- http://acm.hdu.edu.cn/showproblem.php?pid=2866
- http://acm.hdu.edu.cn/showproblem.php?pid=1041
- http://acm.hdu.edu.cn/showproblem.php?pid=1719
- http://acm.hdu.edu.cn/showproblem.php?pid=2136
- http://acm.hdu.edu.cn/showproblem.php?pid=1166
- http://acm.hdu.edu.cn/showproblem.php?pid=3519
- http://acm.hdu.edu.cn/showproblem.php?pid=2446
- http://acm.hdu.edu.cn/showproblem.php?pid=1709
- http://acm.hdu.edu.cn/showproblem.php?pid=1874
- http://acm.hdu.edu.cn/showproblem.php?pid=1863
- http://acm.hdu.edu.cn/showproblem.php?pid=1879
- http://acm.hdu.edu.cn/showproblem.php?pid=1875
- http://acm.hdu.edu.cn/showproblem.php?pid=1102
- http://acm.hdu.edu.cn/showproblem.php?pid=1162
- Makefile中自定义变量
- iOS中的block和retain cycle (经典)
- vsftpd匿名用户新建目录错误信息:550 Create directory operation failed
- MinGW在Win7下的按装、设置和使用,出现error: SDKDDKVer.h: No such file or directory
- 2014百度之星第二题Disk Schedule(双调欧几里得旅行商问题+DP)
- http://acm.hdu.edu.cn/showproblem.php?pid=3336
- 简单的JTML+JS验证用户名、电话号码格式_JS自定义function_正则表达式
- 命令与文件的搜寻
- 喝白玉堂冬瓜荷叶茶找回苗条漂亮的自己
- wayland helloworld (二) 之Wayland鼠标消息
- jquery datatable 参数
- 【TED演讲】邦克·罗伊:从赤脚运动中学习
- 屏幕输出VS文件输出
- Block(1)