#include<iostream>
#include<stdio.h>
#define MAXN 1000001
using namespace std; char c[MAXN];
int next[MAXN]; void give_next(int len)
{
int i;
int j;
i=,j=-;
next[]=-;
while(i < len)
{
if(j == - || c[i] == c[j])
{
i ++;
j ++;
next[i] = j;
}
else
j = next[j];
}
} int main()
{
//freopen("acm.acm","r",stdin);
int size;
int tem;
int tem1;
int time = ;
while(scanf("%d",&size) != EOF,size)
{
cout<<"Test case #"<<++ time<<endl;
scanf("%s",c);
int i;
give_next(size);
for(i = ; i <= size; ++ i)
{
if(next[i-] != -)
{
tem = i - (next[i]);
if(i % tem == )
{
tem1 = i/tem;
if(tem1 > )
cout<<i<<" "<<tem1<<endl;
}
}
}
cout<<endl;
}
}

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 1961的更多相关文章

  1. POJ 1961 2406 (KMP,最小循环节,循环周期)

    关于KMP的最短循环节.循环周期,请戳: http://www.cnblogs.com/chenxiwenruo/p/3546457.html (KMP模板,最小循环节) POJ 2406  Powe ...

  2. KMP POJ 1961 Period

    题目传送门 /* 题意:求一个串重复出现(>1)的位置 KMP:这简直和POJ_2406没啥区别 */ /******************************************** ...

  3. Period POJ - 1961

    Period POJ - 1961 时限: 3000MS   内存: 30000KB   64位IO格式: %I64d & %I64u 提交 状态 已开启划词翻译 问题描述 For each ...

  4. POJ 1961 Period(KMP)

    http://poj.org/problem?id=1961 题意 :给你一个字符串,让你输出到第几个字符时,循环结的个数. 思路 :这个题和2409差不多,稍微修改一下,加一个循环就行了,用的也是K ...

  5. POJ 1961 Period KMP算法next数组的应用

    题目: http://poj.org/problem?id=1961 很好的题,但是不容易理解. 因为当kmp失配时,i = next[i],所以错位部分就是i - next[i],当s[0]...s ...

  6. poj 1961 Period

    Period http://poj.org/problem?id=1961 Time Limit: 3000MS   Memory Limit: 30000K       Description Fo ...

  7. poj 1961 Period 【KMP-next前缀数组的应用】

    题目地址:http://poj.org/problem?id=1961 Sample Input 3 aaa 12 aabaabaabaab 0 Sample Output Test case #1 ...

  8. POJ 1961 Period( KMP )*

    Period Time Limit: 3000MSMemory Limit: 30000K Total Submissions: 12089Accepted: 5656 Description For ...

  9. (简单) POJ 1961 Period,扩展KMP。

    Description For each prefix of a given string S with N characters (each character has an ASCII code ...

  10. POJ 1961 循环节

    和POJ 2406 几乎一样.前者是求 该字符串的最小的循环节.也就是最大的循环次数.后者是求该字符串的每个前缀的循环节的最大循环次数.(如果有的话).而且必须大于1.才可以输出.就是POJ 2406 ...

随机推荐

  1. hdu 1029

    #include"stdio.h" int main(void) { int n,x,y,t,i; while(scanf("%d",&n)!=EOF) ...

  2. jquery easyui datebox单击文本框显示日期选择

    jquery easyui的datebox日历控件,实现单击文本框出现日历选择,如下图: 代码: 修改jquery.easyui.min.js第9797行函数(jQuery EasyUI 1.3.2) ...

  3. 反射 reflect 初始学习

    类也是对象,本身是java.lang.Class 类的对象. Class的三种表示方式: 1.Class a = A.class: 类名.class的方式.经常在日志记录里面,获取当前类的日志记录生成 ...

  4. hdu 2034 人见人爱A-B

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Description 参加过上个月月赛的同学一定还记得其中的一个最简单的题目, ...

  5. hdu 2680 Choose the best route

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2680 Choose the best route Description One day , Kiki ...

  6. Swift 1.2 正式发布 - 带来很多重大改进

    Swift 1.2 随着 Xcode 6.3 Beta 正式发布了.这次的 beta 发布包含了对 Swift 编译器显著的改进.还有对 Swift 语言本身的新特性的增加.这篇文章介绍下主要部分. ...

  7. extjs实现多国语音切换

    http://kuyur.info/blog/archives/2490 http://blog.chinaunix.net/uid-28661623-id-3779637.html http://b ...

  8. 位bit——字节Byte???

    1.换算 每8个位(bit)组成一个字节(byte) 位bit简写为小写字母“b”,字节Byte简写为大写字母“B” 8*b=1*B 1024*B=1*KB 1024*K=1MB 2.举例 一个英文字 ...

  9. 自定义debug信息

    #ifdef  DEBUG  #define debug(fmt,args...)  printk(fmt ,##args)  #define debugX(level,fmt,args...) if ...

  10. linux校准时间

    Linux下ntpdate时间同步 Ntp服务器安装配置 ntp(Network Time Protocol)协议 RedHat服务器可以下载rpm安装包,然后执行# rpm -ivh ntp-4.2 ...