当前位置:网站首页>poj1961 Period(KMP)
poj1961 Period(KMP)
2022-08-08 17:24:00 【51CTO】
C - Period
Crawling in process...
Crawling failed
Time Limit:3000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64u
Submit Status Practice POJ 1961
System Crawler (2016-05-10)
Description
For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 <= i <= N) we want to know the largest K > 1 (if there is one) such that the prefix of S with length i can be written as A K ,that is A concatenated K times, for some string A. Of course, we also want to know the period K.
Input
The input consists of several test cases. Each test case consists of two lines. The first one contains N (2 <= N <= 1 000 000) – the size of the string S.The second line contains the string S. The input file ends with a line, having the
number zero on it.
Output
For each test case, output "Test case #" and the consecutive test case number on a single line; then, for each prefix with length i that has a period K > 1, output the prefix size i and the period K separated by a single space; the prefix sizes must be in increasing order. Print a blank line after each test case.
Sample Input
Sample Output
第二次做KMP算法了 可惜的是我见到了都不知道是要用KMP算法做 唉
上次做也没有深刻理解next数组的意义 做了这道题 让我理解到 (仅仅是我的理解,错了别喷我。。)next数组的作用就是在匹配主串的时候
遇到了不相同的字符 通过next数组快速跳过已经匹配过的字符。具体解释请看这位大牛写的
做了这道题也知道了next数组可以找循环节 唉 真的想不到
边栏推荐
猜你喜欢

五、jmeter脚本的基本构成&断言

差分约束做法

VISTA无人驾驶模拟器;FinRL量化金融深度强化学习库;『深度神经网络应用』电子书;CUDA/TensorRT案例集锦;前沿论文 | ShowMeAI资讯日报

DSPE-PEG-NH2,DSPE-PEG-amine,474922-26-4,磷脂-聚乙二醇-氨基科研试剂

【CC3200AI 实验教程4】疯壳·AI语音人脸识别(会议记录仪/人脸打卡机)-GPIO

LeetCode_Binary Tree_Medium_515. Find the maximum value in each tree row

【开源教程2】疯壳·开源编队无人机-硬件资源简介

Reprinted, the fragment speaks very well, the big guy

转载,fragment讲的很好的大佬

4. S32K14X study notes: S32 Design Studio new and imported projects
随机推荐
数据库分析与优化
目标检测、目标跟踪、图像分类最新进展
B+树与B-树的区别
Chapter 20 Source Code File REST API Reference (2)
3531. 哈夫曼树
【教程2】疯壳·ARM功能手机-测试程序介绍
咸阳广发证券股票开户安全吗,需要准备什么证件
使用电脑通过VNC Viewer远程连接树莓派4B
LeetCode_二叉树_中等_515.在每个树行中找最大值
正则在js中的使用
转载,fragment讲的很好的大佬
字节一面:TCP 和 UDP 可以使用同一个端口吗?
通俗易懂的epoll
2022-08-08日报:Kaggle所有竞赛开源方案和Top思路汇总
The difference between B+ tree and B- tree
七、jmeter发出请求的逻辑
dp,dpi,px知识补充
Subject: Ordered Queue
L2-020 功夫传人 (25 分)
测试/开发程序员停滞不前,倦怠怎么办?突破各种失败和挫折......