博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Power Strings(KMP)
阅读量:7309 次
发布时间:2019-06-30

本文共 1205 字,大约阅读时间需要 4 分钟。

Power Strings
Time Limit: 3000MS   Memory Limit: 65536K
Total Submissions: 45008   Accepted: 18794

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

Hint

This problem has huge input, use scanf instead of cin to avoid time limit exceed.

Source

#include
#include
#include
#include
#define N 1000010using namespace std;int next[N];char str[N];void getnext(char str[],int next []){ next[0]=next[1]=0; int len=strlen(str); for(int i=1;i

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/5978395.html

你可能感兴趣的文章
SpringBoot+devtools 热部署
查看>>
解决CentOS7安装后没有Killall或ifconfig命令
查看>>
给各位分享PHP常用函数
查看>>
在宏中使得字段只能读取 (几何画板开发笔记 三)
查看>>
leptonica & tesseract & tess4j
查看>>
adb命令启动展讯平台工厂模式
查看>>
linux scp远程拷贝文件及文件夹
查看>>
Apache随机出现403 Forbidden探析
查看>>
Eclipse背景颜色设置(设置成豆沙绿色保护眼睛,码农保护色)
查看>>
sql server触发器知识点储备
查看>>
exchange
查看>>
自定义菜单控制程序
查看>>
mysql的备份-完全备份
查看>>
SELinux笔记
查看>>
使用switch(true) 代替冗长的if-else
查看>>
开源企业级数字化服务平台——Choerodon猪齿鱼发布0.11版本
查看>>
JAVA多重继承的实现
查看>>
rsyncd.conf 教程
查看>>
python入门(二)数据库操作
查看>>
Python 中的 10 个常见安全漏洞,以及如何避免(下)
查看>>