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 ...
随机推荐
- ZooKeeper系列(二)
Zookeeper的环境配置 一.Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式. 1.单机模式:Zookeeper只运行在一台服务器上,适合测试环境 ...
- Ryubook_1_switch_hub_部署执行
一.环境: mininet.ovs.Ryu. 二.实验过程: 1.搭建拓扑: 执行sudo mn --topo single,3 --mac --switch ovsk --controller re ...
- js 给url添加时间戳 解决浏览器缓存
//解决浏览器缓存 function timestamp(url){ // var getTimestamp=Math.random(); var getTimestamp=new Dat ...
- 查询SQLServer2005中某个数据库中的表结构、索引、视图、存储过程、触发器以及自定义函数
查询SQLServer2005中某个数据库中的表结构.索引.视图.存储过程.触发器以及自定义函数 2013-03-11 09:05:06| 分类: SQL SERVER|举报|字号 订阅 ( ...
- Server.MapPath() 用法
Server.MapPath() ./当前目录/网站主目录../上层目录~/网站虚拟目录 如果当前的网站目录为E:\wwwroot 应用程序虚拟目录为E:\wwwroot\company 浏览的页 ...
- jQuery-图片的放大镜显示效果方法封装
(function($){ $.fn.jqueryzoom = function(options){ var settings = { xzoom: 200, //zoomed width defau ...
- 杀了个回马枪,还是说说position:sticky吧
<style> article { max-width: 600px; margin: 1em auto; } article h4, article footer { position: ...
- Linux基础学习一
swap:虚拟内存ctrl+a:跳到命令首部 ctrl+e:跳到命令尾部alias:指令别名cp -r:递归复制粘贴mv 源路径 目标路径:移动操作 (如果提示是否覆盖,在mv前加\即可不提示:\mv ...
- mysql 存储过程批量删除重复数据
表结构: LOAD DATA INFILE '/usr/local/phone_imsi_12' replace INTO TABLE tbl_imsi2number_new FIELDS TERMI ...
- http主要请求头
一.内容协商 1.Accept:希望服务器返回的数据格式,如下面的:text/javascript, application/javascript, application/ecmascript, a ...