POJ——T 2406 Power Strings
http://poj.org/problem?id=2406
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 50627 | Accepted: 21118 |
Description
Input
Output
Sample Input
abcd
aaaa
ababab
.
Sample Output
1
4
3
Hint
Source
#include <algorithm>
#include <cstring>
#include <cstdio> using namespace std; const int N();
int ans,len,p[N];
char s[N]; inline void Get_next()
{
for(int i=,j=;i<=len;i++)
{
for(;s[i]!=s[j+]&&j>;) j=p[j];
if(s[i]==s[j+]) j++;
p[i]=j;
}
} int main()
{
for(scanf("%s",s+);s[]!='.';scanf("%s",s+))
{
memset(p,,sizeof(p));
len=strlen(s+);
Get_next();
int tmp=len-p[len];
if(len%tmp) puts("");
else printf("%d\n",len/tmp);
}
return ;
}
POJ——T 2406 Power Strings的更多相关文章
- 【POJ】2406 Power Strings
http://poj.org/problem?id=2406 题意:给定一个字符串 L,已知这个字符串是由某个字符串 S 重复 R 次而得到的,求 R 的最大值.(长度<=1000000) #i ...
- poj 2406 Power Strings (kmp 中 next 数组的应用||后缀数组)
http://poj.org/problem?id=2406 Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submiss ...
- poj 2406 Power Strings 后缀数组解法
连续重复子串问题 poj 2406 Power Strings http://poj.org/problem?id=2406 问一个串能否写成a^n次方这种形式. 虽然这题用kmp做比较合适,但是我们 ...
- KMP POJ 2406 Power Strings
题目传送门 /* 题意:一个串有字串重复n次产生,求最大的n KMP:nex[]的性质应用,感觉对nex加深了理解 */ /************************************** ...
- POJ 2406 Power Strings (KMP)
Power Strings Time Limit: 3000MSMemory Limit: 65536K Total Submissions: 29663Accepted: 12387 Descrip ...
- POJ 2406 Power Strings
F - Power Strings Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u S ...
- KMP + 求最小循环节 --- POJ 2406 Power Strings
Power Strings Problem's Link: http://poj.org/problem?id=2406 Mean: 给你一个字符串,让你求这个字符串最多能够被表示成最小循环节重复多少 ...
- poj 2406:Power Strings(KMP算法,next[]数组的理解)
Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 30069 Accepted: 12553 D ...
- poj 2406 Power Strings kmp算法
点击打开链接 Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 27368 Accepted: ...
随机推荐
- NodeJS学习笔记 进阶 (7)express+session实现简易身份认证(ok)
个人总结: 这篇文章讲解了express框架中如何使用session,主要用了express-session这个包.更多可以参考npm.js来看,读完这篇文章需要10分钟. 摘选自网络: 文档概览 本 ...
- linux命令find命令详解
find 查找文件 find 哪里 什么类型 什么名字 -maxdepth 最大的深度 查找目录的最大深度 find -maxdepth 1 -type d -type 找什么类型的 f fil ...
- nl---统计行号
nl命令读取 file 参数(缺省情况下标准输入),计算输入中的行号,将计算过的行号写入标准输出.在输出中,nl命令根据您在命令行中指定的标志来计算左边的行.输入文本必须写在逻辑页中.每个逻辑页有头. ...
- 10-while和dowhile语句
- 洛谷——P1970 花匠
https://www.luogu.org/problem/show?pid=1970 题目描述 花匠栋栋种了一排花,每株花都有自己的高度.花儿越长越大,也越来越挤.栋栋决定 把这排中的一部分花移走, ...
- 【翻译自mos文章】私有网络所用的协议 与 Oracle RAC
说的太经典了,不敢翻译.直接上原文. 来源于: Network Protocols and Real Application Clusters (文档 ID 278132.1) PURPOSE --- ...
- 实战Jquery(四)--标签页效果
这两天完毕了实战四五六的样例,实例四是标签页的实现方法,实例五是级联菜单下拉框,实例六是窗体效果,都是web层经常使用的效果.越到后面越发认为技术这东西,就是一种思路的展现,懂了要实现 ...
- HIToj--1076--Ordered Fractions(水题)
Ordered Fractions Source : Unknown Time limit : 3 sec Memory limit : 32 M Submitted : 1510, Ac ...
- BZOJ 2730 矿场搭建 Tarjan求割点
思路: Tarjan求出来点双&割点 判一判就行了 //By SiriusRen #include <stack> #include <cstdio> #include ...
- css3 实现加载滚动条效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...