#include<iostream>
#include<string.h>
#include<stdio.h>
#define N 1000010
using namespace std;
char s[N];
int next[N];
void getnext(char s[])
{
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 j=1,i,n;
while(cin>>n)
{
if(n==0)
{
break;
}
else
cin>>s;
getnext(s);
cout<<"Test case #"<<j<<endl;
j++;
for(i=2;i<=n;i++)
{
if(i%(i-next[i])==0 && i!=i-next[i])
cout<<i<<" "<<(i/(i-next[i]))<<endl;
}
cout<<"\n";
}
return 0;
}

SDUTOJ 2476Period的更多相关文章

  1. sdutoj 2151 Phone Number

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2151 Phone Number Time Li ...

  2. sdutoj 2610 Boring Counting

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2610 Boring Counting Time ...

  3. sdutoj 2609 A-Number and B-Number

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2609 A-Number and B-Numbe ...

  4. sdutoj 2624 Contest Print Server

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2624 Contest Print Server ...

  5. sdutoj 2608 Alice and Bob

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time L ...

  6. sdutoj 2623 The number of steps

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2623 The number of steps ...

  7. sdutoj 2606 Rubik’s cube

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2606 Rubik’s cube Time Li ...

  8. sdutoj 2605 A^X mod P

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2605 A^X mod P Time Limit ...

  9. 关键路径 SDUTOJ 2498

    SDUTOJ 2498 AOE网上的关键路径 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 一个无环的有向图称为无环图(Dire ...

随机推荐

  1. C++ class、struct区别

    一.默认访问控制不同(最主要) struct默认为public,class默认为private.这个访问控制既是指成员的默认访问属性,又指继承时默认的继承属性. 二.定义template时不同 在模版 ...

  2. cf536b——优先队列的运用

    题目 题目:cf536 B题 题目大意:一个饭店有n种食物,每种食物有对应的价格和数量,然后有m个顾客,每个顾客需要$d_j$份第$t_j$种食物,如果该种食物数量不够,则选其它尽可能便宜的代替(出现 ...

  3. col - 过滤掉输入中的反向换行符

    SYNOPSIS(总览) col [-bfx ] [ Fl l Ar num ] DESCRIPTION(描述) Col 过滤掉反向(以及半反向)换行符(LF: line feed or NL: ne ...

  4. JavaSE-12 面向对象程序设计的几条基础原则

    摘取代码中变化的行为,形成接口 在设计基类的时候,如果该类某个成员方法在子类中的实现变化差别比较大(一部分子类实现该方法是相同的),作为基类有两个问题:一是该方法不再通用:二是子类如果重写该方法,存在 ...

  5. 【传智播客】Libevent学习笔记(一):简介和安装

    目录 00. 目录 01. libevent简介 02. Libevent的好处 03. Libevent的安装和测试 04. Libevent成功案例 00. 目录 @ 01. libevent简介 ...

  6. 笔试算法题(52):简介 - KMP算法(D.E. Knuth, J.H. Morris, V.R. Pratt Algorithm)

    议题:KMP算法(D.E. Knuth, J.H. Morris, V.R. Pratt Algorithm) 分析: KMP算法用于在一个主串中找出特定的字符或者模式串.现在假设主串为长度n的数组T ...

  7. Python 面向对象 组合-多态与多态性-封装-property

    面向对象-组合 1.什么是组合 组合指的是某一个对象拥有一个属性,该属性的值是另外一个类的对象 class Foo: xxx = 111 class Bar: yyy = 222 obj = Foo( ...

  8. openwrt 配置samba && ubuntu 配置samba

    前言:在修改opkg update的下载目录,公司里不能连外网,尝试用samba. 配置samba很简单,修改/etc/config/samba文件,拷贝一下share项,再改一下name就可以了. ...

  9. SAX解析XML-例子

    1.要解析的xml <?xml version="1.0" encoding="UTF-8"?> <employees> <emp ...

  10. Java中的日期、时间操作

    每次在处理日期时间的时候都要打开chrome查找一番,索性自己找一下满意的记录下来. 一.时间格式 // hh表示12小时制: HH表示24小时制 SimpleDateFormat format1 = ...