<pre class="cpp" name="code">#include<iostream>
#include<stdio.h>
#include<string.h>
#define N 1000005
int next[N];
char s[N];
using namespace std;
void getnext(char s[])//KMP算法的应用
{
int j=-1,i=0,len;
next[0]=-1;
len=strlen(s);
while(i<=len)
{
if(j==-1||s[i]==s[j])
{
++i;
++j;
next[i]=j;
}
else
j=next[j];
}
}
int main()
{
int len;
while(cin>>s)
{
if(s[0]=='.')
{
break;
}
len=strlen(s);
getnext(s);
if(len%(len-next[len])==0)
cout<<(len/(len-next[len]))<<endl;//求最小循环节..事实上题意就是这个意思
}
return 0;
}


SDUTOJ 2475 Power Strings的更多相关文章

  1. POJ 2406 Power Strings (KMP)

    Power Strings Time Limit: 3000MSMemory Limit: 65536K Total Submissions: 29663Accepted: 12387 Descrip ...

  2. POJ 2406 Power Strings

    F - Power Strings Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u S ...

  3. poj 2406:Power Strings(KMP算法,next[]数组的理解)

    Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 30069   Accepted: 12553 D ...

  4. POJ 2406:Power Strings

    Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 41252   Accepted: 17152 D ...

  5. E - Power Strings,求最小周期串

    E - Power Strings Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u S ...

  6. poj 2406 Power Strings kmp算法

    点击打开链接 Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 27368   Accepted:  ...

  7. poj 2406 Power Strings (kmp 中 next 数组的应用||后缀数组)

    http://poj.org/problem?id=2406 Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submiss ...

  8. 【POJ2406】 Power Strings (KMP)

    Power Strings Description Given two strings a and b we define a*b to be their concatenation. For exa ...

  9. Power Strings

    Power Strings TimeLimit: 1 Second   MemoryLimit: 32 Megabyte Totalsubmit: 1791   Accepted: 528 Descr ...

随机推荐

  1. 剑指offer8 旋转数组的最小数字

    一种错误写法: class Solution { public: int minNumberInRotateArray(vector<int> rotateArray) { int len ...

  2. faster rcnn训练过程讲解

    http://blog.csdn.net/u014696921/article/details/60321425

  3. PRJ0003 : Error spawning 'midl.exe'

    原因:出现该错误的是由于:C:\Program Files\Microsoft SDKs\Windows\v6.0A midl.exe 和midlc.exe缺失. 解决方法:从别人电脑上拷贝这个两个文 ...

  4. css3新增属性:多列(column)

    css3多列能够创建多个列来对文本进行布局,就想报纸那样. 关于多列的相关属性及属性值如下: column-count: number|auto;:指定元素应分为的列数.column-fill: 指定 ...

  5. springmvc请求方法那些事

    @RequestMapping 用法详解之地址映射 (2013-08-11 16:06:58) 转载▼ 标签: it   前段时间项目中用到了RESTful模式来开发程序,但是当用POST.PUT模式 ...

  6. Node.js 创建server服务器

    var http=require('http'); //引入http模块 var server=http.createServer(function(req,res){  //创建一个server r ...

  7. NOIp2018 提高组初赛试题参考答案

  8. [题解] cogs 2240 架设电话线路

    http://cogs.pro:8080/cogs/problem/problem.php?pid=2240 与洛谷P2885几乎一致,https://www.luogu.org/problemnew ...

  9. 全新Ubentu系统没有make,gcc命令解决办法

    一定要记得先update sudo apt-get update 然后输入下述命令即可 sudo apt-get install make sudo apt-get install gcc

  10. 2019天梯赛练习题(L1专项练习)

    7-1 水仙花数 (20 分) 水仙花数是指一个N位正整数(N≥3),它的每个位上的数字的N次幂之和等于它本身.例如:1. 本题要求编写程序,计算所有N位水仙花数. 输入样例: 3 输出样例: 153 ...