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 ...
随机推荐
- 看到了一篇不错的tensorflow文章
http://dataunion.org/28906.html 本文作者 Steven Dufresne,总结了新手学 TensorFlow 需要的核心知识点和实操内容,旨在鼓励更多人借 Tensor ...
- Importing Swift into Objective-C
Overview You can work with types declared in Swift from within the Objective-C code in your project ...
- bind - 将一个名字和一个套接字绑定到一起
SYNOPSIS 概述 #include <sys/types.h> #include <sys/socket.h> int bind(int sockfd, struct s ...
- 取消input聚焦时的边框,去除ios点击时,自动添加的底色效果
/*去除ios点击时,自动添加的底色效果*/ -webkit-tap-highlight-color: rgba(, , , ); /*去除焦点框*/ outline:none;
- NPOI--------------.Net操作Excel初步使用(导出)
背景 因公司项目需要添加数据导出功能故此添加,找了几种方式发现该方式具有 无需依赖本机安装office环境,使用灵活等优点故采用此方式. 安装 Nuget 直接安装NPOI即可 使用方式 1.根据需要 ...
- java实现zip,gzip,7z,zlib格式的压缩打包
本文主要介绍的是通过使用java的相关类可以实现对文件或文件夹的压缩. zlib是一种数据压缩程序库,它的设计目标是处理单纯的数据(而不管数据的来源是什么). 7z 是一种新的压缩格式,它拥有目前最高 ...
- 牛客网 nowcoder TG test-172
# solution-nowcoder-172 # A-中位数 $30\%:n\le 200$ 直接枚举 $n-len+1$ 个区间,将这段里的数重新排序直接找到中位数 $60\%:n\le 2000 ...
- Kali Linux 下载、引导、安装
下载卡莉 Linux 官方镜像: https://www.kali.org/downloads/ 官方虚拟机镜像: https://www.offensive-security.com/kali-li ...
- xcap发包工具的简单使用3(报文描述)
之前详细介绍了如何构造以及发送报文,现在简单对报文描述一下 1.Ethernet MAC:填写报文目的mac和源mac地址 Vlan:支持单vlan,QinQ,如果有更多的vlan,请填写在“More ...
- Java面向对象学习-----类的成员变量
类的成员变量: 猜数字游戏:一个类A有一个成员变量v,通过随机产生一个100内的整数给v赋值.定义一个方法,对A类的成员变量v进行猜. 没有猜对的情况下提示如果大了则提示大了,小了则提示小了,并且 ...