SDUTOJ 2476Period
#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的更多相关文章
- sdutoj 2151 Phone Number
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2151 Phone Number Time Li ...
- sdutoj 2610 Boring Counting
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2610 Boring Counting Time ...
- sdutoj 2609 A-Number and B-Number
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2609 A-Number and B-Numbe ...
- sdutoj 2624 Contest Print Server
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2624 Contest Print Server ...
- sdutoj 2608 Alice and Bob
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time L ...
- sdutoj 2623 The number of steps
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2623 The number of steps ...
- sdutoj 2606 Rubik’s cube
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2606 Rubik’s cube Time Li ...
- sdutoj 2605 A^X mod P
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2605 A^X mod P Time Limit ...
- 关键路径 SDUTOJ 2498
SDUTOJ 2498 AOE网上的关键路径 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 一个无环的有向图称为无环图(Dire ...
随机推荐
- cf536b——优先队列的运用
题目 题目:cf536 B题 题目大意:一个饭店有n种食物,每种食物有对应的价格和数量,然后有m个顾客,每个顾客需要$d_j$份第$t_j$种食物,如果该种食物数量不够,则选其它尽可能便宜的代替(出现 ...
- linux 配置Java、Mysql、Tomcat、Redis开发环境
1.安装四个依赖 以下四个依赖必须按顺序联网安装:yum install glibc.i686yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so ...
- vue之Render函数
(1)什么是Render函数 先来看一个场景,在博客网中,一般有一级标题.二级标题.三级标题...,为了方便分享url,它们都做成了锚点,点击后,会将内容加载网址后面,以#分隔. 例如‘特性’是一个& ...
- Eclipse使用入门指南及技巧
Java是必须的 安装一个JDK就可以了,比如jdk-6u39-windows-x64.exe,安装完毕,会自行安装JRE. 如果不用IDE,这个时候用记事本也是可以写程序,然后用javac编译, ...
- 第2节 mapreduce深入学习:14、mapreduce数据压缩-使用snappy进行压缩
第2节 mapreduce深入学习:14.mapreduce数据压缩-使用snappy进行压缩 文件压缩有两大好处,节约磁盘空间,加速数据在网络和磁盘上的传输. 方式一:在代码中进行设置压缩 代码: ...
- CocoaPods 命令和使用
CocoaPods 命令 pod init 在新建的项目根目录下运行该命令,为当前项目新建podfile文件. pod install 下载和配置 podfile里定义的项目依赖(不包括已经下载和配置 ...
- viewDidLoad等相关函数调用
viewDidLoad 此方法只有当view从nib文件初始化的时候才被调用.viewDidLoad用于初始化,加载时用到的. loadView 此方法在控制器的view为nil的时候被调用.虽然经常 ...
- 文本框/域文字提示(placeholder)自动显示隐藏jQuery小插件
// 文本框文本域提示文字的自动显示与隐藏 (function($){ $.fn.textRemindAuto = function(options){ options = options || {} ...
- Luogu P4299 首都 LCT
既然是中文题目,这里便不给题意. 分析: 这个题的做法据说是启发式合并? 但是我不会啊…… 进入正题,LCT是怎样做掉这道题的.记得在前面的一篇<大融合>的题解中,介绍过LCT维护子树信息 ...
- 模板BSGS(SDOI2011计算器) 模板EXBSGS
BSGS和EXBSGS是OI中用于解决A^xΞB(mod C)的常用算法. 1.BSGS BSGS用于A,C互质的情况. 令m=sqrt(C),此时x可表示为i*m+j. 式中i和j都<=sqr ...