数据结构之KMP算法---poj2406---Power Strings
发布日期:2022-02-02 02:58:09
浏览次数:22
分类:技术文章
本文共 970 字,大约阅读时间需要 3 分钟。
Description
Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in the normal way: a^0 = "" (the empty string) and a^(n+1) = a*(a^n).
Input
Each test case is a line of input representing s, a string of printable characters. The length of s will be at least 1 and will not exceed 1 million characters. A line containing a period follows the last test case.
Output
For each s you should print the largest n such that s = a^n for some string a.
Sample Input
abcdaaaaababab.
Sample Output
143代码实现:
#include#include #define max 1000001using namespace std;int next[max];char str[max];int getnext(char *str){ int i=0,j=-1; int len=strlen(str); next[0]=-1; while(i >str) { if(str[0]=='.')break; int ans=getnext(str); cout< <
转载地址:https://blog.csdn.net/u010368749/article/details/19341149 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
逛到本站,mark一下
[***.202.152.39]2024年03月08日 23时52分18秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
java io流过滤流_IO流分类详细介绍和各种字节流类介绍与使用 过滤流 字节流
2019-04-21
java预处理指令_Java程序员学C++_1_C++中的预处理命令 | 学步园
2019-04-21
java中的%不对 如何处理_Java心得--异常及其处理
2019-04-21
java 上传速度计算_java常见3种文件上传速度对比和文件上传方法详细代码
2019-04-21
java 试图模版_图解Java设计模式之模板模式
2019-04-21
支付宝 java 乱码_支付宝即时到账接口中文乱码问题
2019-04-21
java中的handler理解_handler 与message的一些理解
2019-04-21
JAVA礼物题_这些Java面试题,你一定要记住!
2019-04-21
java 隐藏email_java Email
2019-04-21
linux下qt浏览word文件内容,Qt获取office文件内容
2019-04-21
amd锐龙笔记本cpu怎么样_不知不觉已经15款 AMD Ryzen锐龙笔记本处理器盘点
2019-04-21
syslog打印不带等级_(转)syslog日志等级
2019-04-21
librosa能量_librosa语音信号处理
2019-04-21
android日期选择区间控件_Android时间区间的选择
2019-04-21
lin通讯从节点同步间隔场_LIN模块介绍
2019-04-21
mysql注入提取邮件_Mysql提取数据每日自动邮件通知
2019-04-21
mysql 列权限_mysql 权限相关
2019-04-21