博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ---2406 Power Strings[求最长重复字串]
阅读量:4936 次
发布时间:2019-06-11

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

Power Strings
Time Limit: 3000MS   Memory Limit: 65536K
Total Submissions: 23735   Accepted: 9978

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

 
 
 
题意:给出一个字符串S,求该字符串最多是由相同重复字串连接而成的
若S由n个A组成,则称 S = A^n,求最大的n
  如 S=aaa,S="a"^3 => n = 3;      S=ababa =>  n = 1       S=ababab=>"ab"^3=>n=3
 
code:
1 #include
2 #include
3 using namespace std; 4 5 int Next[1000010]; 6 char str[1000010]; 7 int len; 8 9 void getnext()10 {11 int j=0;12 int k=-1;13 Next[0]=-1;14 while(j

 

转载于:https://www.cnblogs.com/XBWer/archive/2012/09/04/2669823.html

你可能感兴趣的文章
Jmeter计数器的使用-转载
查看>>
【Android笔记】入门篇02:全屏设置和禁止横屏竖屏切换
查看>>
Kubernetes的本质
查看>>
PL/SQL developer 管理多套数据库
查看>>
黑马程序员-分类(category)
查看>>
vue-cli多页面
查看>>
进程和线程
查看>>
iOS Foundation框架简介 -1.常用结构体的用法和输出
查看>>
libevent reference Mannual I
查看>>
eclipse创建Maven父子结构Maven项目
查看>>
Python 太糟糕了?开发者总结了 8 大原因
查看>>
Spring中注入基本类型
查看>>
脚本方式安装 IIS7
查看>>
Oracle password expire notices
查看>>
发现“郝茵晴”:屌丝们的社会性传播实验
查看>>
WordPress优化:为网站添加个性化缩略图标
查看>>
shell脚本分析IP归属地
查看>>
CITRIX XenAPP/TS打印管理ThinPrint.
查看>>
SQL Server以Online模式创建索引
查看>>
微软开放 .NET 框架源代码
查看>>