51NOD1277 字符串中的最大值
来源:互联网 发布:黑人 知乎 编辑:程序博客网 时间:2024/06/08 07:19
题目链接:传送门
kmp裸题
因为前缀是从长到短覆盖的,所以从长到短累计加和
贴代码
var s:ansistring; n,i,j:longint; a:array[0..100005]of char; f,p:array[0..100005]of longint; ans:int64; begin// assign(input,'1277.in');reset(input);// assign(output,'1277.out');rewrite(output); readln(s); n:=length(s); for i:=1 to n do a[i]:=s[i]; fillchar(p,sizeof(p),0); j:=0; for i:=2 to n do begin while (j>0)and(a[j+1]<>a[i]) do j:=p[j]; if a[j+1]=a[i] then inc(j); p[i]:=j; end; ans:=0; fillchar(f,sizeof(f),0); for i:=n downto 1 do begin inc(f[i]); inc(f[p[i]],f[i]); end; for i:=1 to n do if int64(i)*int64(f[i])>ans then ans:=int64(i)*int64(f[i]); writeln(ans);// close(input);close(output); end.
【写的有漏洞的,欢迎路过大神吐槽】
2017/09/06 22:58:56
Ending.
阅读全文
1 0
- 【51Nod1277】字符串中的最大值
- 51NOD1277 字符串中的最大值
- 51nod1277 字符串中的最大值(KMP)
- KMP——51nod1277 字符串中的最大值
- [KMP fail树] 51nod1277 字符串中的最大值
- 【KMP-fail树】51Nod1277[字符串中的最大值]题解
- 【51Nod1292】字符串中的最大值
- [51nod 1292]字符串中的最大值V2
- 51nod-1277 字符串中的最大值(KMP)
- 51nod 1277 字符串中的最大值
- 51nod 1277 字符串中的最大值
- kmp-51nod 1277 字符串中的最大值
- 51nod 1277 字符串中的最大值
- 51Nod-1277-字符串中的最大值
- 51 nod 1277 字符串中的最大值(KMP)
- 51Nod-1277-字符串中的最大值
- 51nod 1277 字符串中的最大值(KMP)
- [KMP next树] 51Nod 1277 字符串中的最大值
- 在字符串中找出连续最长的数字串
- 机器学习学习笔记.day1
- springboot schedule
- Android控件之ViewFlipper
- 绕过htaccess的限制工具-HTExploit
- 51NOD1277 字符串中的最大值
- Codeforces 854 A Fraction
- 使用@WebServlet配置loadOnStartup的时候不起作用的解决方法
- Quartz应用与集群原理分析
- Redis常用命令总结,建议收藏备用
- Python面向对象(基础整理)
- Visual Studio 2015中的常用调试技巧分享
- Coscos2d-x之世界坐标转换为节点坐标、菜单按钮
- TOMCAT源码分析-生命周期管理