kuangbin专题十六 KMP&&扩展KMP POJ2406 Power Strings
Input
Output
Sample Input
abcd
aaaa
ababab
.
Sample Output
1
4
3
Hint
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
using namespace std;
int Next[],n;
char p[]; void prekmp() {
int i,j;
j=Next[]=-;
i=;
while(i<n) {
while(j!=-&&p[i]!=p[j]) j=Next[j];
if(p[++i]==p[++j]) Next[i]=Next[j];
else Next[i]=j;
}
} int main() {
//freopen("in","r",stdin);
while(~scanf("%s",p)) {
if(p[]=='.') break;
n=strlen(p);
prekmp();
int l=n-Next[n];
if(n%l==) printf("%d\n",n/l);
else printf("%d\n",);
}
}
kuangbin专题十六 KMP&&扩展KMP POJ2406 Power Strings的更多相关文章
- kuangbin专题十六 KMP&&扩展KMP HDU2609 How many (最小字符串表示法)
Give you n ( n < 10000) necklaces ,the length of necklace will not large than 100,tell me How man ...
- kuangbin专题十六 KMP&&扩展KMP HDU2328 Corporate Identity
Beside other services, ACM helps companies to clearly state their “corporate identity”, which includ ...
- kuangbin专题十六 KMP&&扩展KMP HDU1238 Substrings
You are given a number of case-sensitive strings of alphabetic characters, find the largest string X ...
- kuangbin专题十六 KMP&&扩展KMP HDU3336 Count the string
It is well known that AekdyCoin is good at string problems as well as number theory problems. When g ...
- kuangbin专题十六 KMP&&扩展KMP POJ3080 Blue Jeans
The Genographic Project is a research partnership between IBM and The National Geographic Society th ...
- kuangbin专题十六 KMP&&扩展KMP HDU3746 Cyclic Nacklace
CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, ...
- kuangbin专题十六 KMP&&扩展KMP HDU2087 剪花布条
一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input输入中含有一些数据,分别是成对出现的花布条和小 ...
- kuangbin专题十六 KMP&&扩展KMP HDU1686 Oulipo
The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...
- kuangbin专题十六 KMP&&扩展KMP HDU1711 Number Sequence
Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M ...
随机推荐
- PowerDesigner的Additional Checkes 中使用统配符
在Domian或字段的的约束条件中,会用的正则表达式等约束.但正则表达式 regexp_like(ICAO,'^([A-Z]{4}$')中要出现明确字段名如ICAO,每个使用同样约束的字段都要修改此字 ...
- springmvc中针对一个controller方法配置两个url请求
转自:https://blog.csdn.net/sun5769675/article/details/50252019
- C语言学习笔记--内存分区
1. 程序中的栈 1.1 栈的简介 (1)栈中现代计算机程序里最为重要的概念之一 (2)栈在程序中用于维护函数调用上下文 (3)函数中的参数和局部变量存储在栈上 (4)栈保存了一个函数调用所需的维护信 ...
- java之控制多幅图片
package xxj.thread0904; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JFra ...
- Mediaplayer
Mediaplayer报错 prepareAsync called in state 1 是因为在setDataSource之前调用了prepare.因为setDataSource放到了线程里 ...
- Emulator PANIC: Could not open: AVD2.3.1
这是这两年的sdk才需要这样,以前这样根本没错的 在环境变量 里面增加一个系统变量ANDROID_SDK_HOME,值就是当前的系统用户文件夹的位置.比如c:\\Users\xxx(不要加.andro ...
- 正则表达式计算 origin = "1 - 2 * ( ( 60 - 30 + ( -40.0 / 5 ) * ( 9 - 2 * 5 / 3 + 7 / 3 * 99 / 4 * 2998 + 10 * 568 / 14 )) - ( - 4 * 3 ) / ( 16 - 3 * 2))"
#!/usr/bin/env python import re def f1(arg): return 1 origin = "1 - 2 * ( ( 60 - 30 + ( -40.0 / ...
- 面试题: 1天的java面试题 已看1
1,自我介绍下,我直接说的项目经历,(哪年在哪个公司呆过) 2,问是否有带过团队的经历,我说去年带过一次. 3,Struts是单例模式还是多例模式?我先说单例模式,后说多例模式. Struts1是单例 ...
- c# ??和运算符先后的问题
; ; - not1??; Console.WriteLine(a); 输出结果为:10 问题因该是??运算符没有-的优先级高,实际这个 操作等于: ; ; - not1)??); 解决这个问题的办法 ...
- php学习笔记-关联数组
传统的数组定义方法如下: <?php $names[0]= 'chinese'; $names[1]= 'math'; $names[2]= 'english'; echo $names[2]; ...