HUST 1010 The Minimum Length
There is a string A. The length of A is less than 1,000,000. I rewrite it again and again. Then I got a new string: AAAAAA...... Now I cut it from two different position and get a new string B. Then, give you the string B, can you tell me the length of the shortest possible string A.
For example, A="abcdefg". I got abcdefgabcdefgabcdefgabcdefg.... Then I cut the red part: efgabcdefgabcde as string B. From B, you should find out the shortest A.
InputMultiply Test Cases.
For each line there is a string B which contains only lowercase and uppercase charactors.
The length of B is no more than 1,000,000.
OutputFor each line, output an integer, as described above.Sample Input
bcabcab
efgabcdefgabcde
Sample Output
3
7 kmp求最小循环节。 代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h> char str[];
int Next[],len,k;
void findNext() {
int j = -,i = ;
Next[] = -;
while(i < len) {
if(j == - || str[i] == str[j]) {
Next[++ i] = ++ j;
}
else j = Next[j];
}
}
int main() {
while(~scanf("%s",str)) {
len = strlen(str);
findNext();///先确立Next数组 printf("%d\n",len - Next[len]);
}
}
HUST 1010 The Minimum Length的更多相关文章
- KMP + 求最小循环节 --- HUST 1010 - The Minimum Length
The Minimum Length Problem's Link: http://acm.hust.edu.cn/problem/show/1010 Mean: 给你一个字符串,求这个字符串的最小循 ...
- HUST 1010 The Minimum Length(KMP,最短循环节点,即i-Next[i])
题意: 有一个字符串A,假设A是“abcdefg”, 由A可以重复组成无线长度的AAAAAAA,即“abcdefgabcdefgabcdefg.....”. 从其中截取一段“abcdefgabcde ...
- hust 1010 The Minimum Length(循环节)【KMP】
<题目链接> 题目大意: 有一个字符串A,一次次的重写A,会得到一个新的字符串AAAAAAAA.....,现在将这个字符串从中切去一部分得到一个字符串B,例如有一个字符串A="a ...
- HUST 1010 The Minimum Length (字符串最小循环节)
题意 有一个字符串A,一次次的重写A,会得到一个新的字符串AAAAAAAA.....,现在将这个字符串从中切去一部分得到一个字符串B.例如有一个字符串A="abcdefg".,复制 ...
- HUST - 1010 The Minimum Length(最小循环节)
1.赤裸裸的最小循环节 2. 3. #include<iostream> #include<stdio.h> #include<string.h> using na ...
- hust1010 The Minimum Length
地址:http://acm.hust.edu.cn/problem/show/1010 题目: 1010 - The Minimum Length Time Limit: 1s Memory Limi ...
- (KMP 求循环节)The Minimum Length
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=70325#problem/F The Minimum Length Time Limit: ...
- F - The Minimum Length
F - The Minimum Length HUST - 1010 #include<cstdio> #include<cstring> #include<iostre ...
- hust--------The Minimum Length (最短循环节)(kmp)
F - The Minimum Length Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...
随机推荐
- [转] 我所经历的IBM SOA与系统整合
2006年,一汽大众新上来一位总经理,新加坡人,整个一国际背景高端管理人才,是德国人和中国人博弈后取得的胜利. 一汽大众过去是从总部到区域到终端一体化的大盘管理模式,很僵化很粘稠,不利用快速反应.于是 ...
- 每天一个Linux命令(57)rpm命令
rpm是一个功能十分强大的软件包管理系统. (1)用法: 用法: rpm [参数] [包名] (2)功能: 功能: 使得在Linux下安装.升级和删除软 ...
- 给嵌入式linux串口添加密码的一些总结
要添加串口登录密码就需要修改 /etc/inittab 文件的配置 但是不同的开发板情况不一样,有的是没有这个文件的,BusyBox会检查/etc/inittab文件是否存在, 如果此文件不存在, B ...
- Linux静默安装weblogic
本实验安装weblogic10系列版本 #创建weblogic用户组. [root@admin /]# groupadd weblogic[root@admin /]# useradd -g webl ...
- jQuery可放大预览的图片滑块
在线演示 本地下载
- matplotlib模块之plot画图
关于matplotlib中一些常见的函数,https://www.cnblogs.com/TensorSense/p/6802280.html这篇文章讲的比较清楚了,https://blog.csdn ...
- 谈Swift中的访问控制
访问控制(Access Control) 访问控制可以限定其他源文件或模块中的代码对你的代码的访问级别.这个特性可以让我们隐藏代码的一些实现细节,并且可以指定一些代码和访问和使用的优先接口. 你可以明 ...
- Android开发 -- Bootloader
本文转载自:http://blog.csdn.net/jmq_0000/article/details/7378348 LK是什么 LK 是 Little Kernel 它是 appsbl (Appl ...
- poj 2828 Buy Tickets 【买票插队找位置 输出最后的位置序列+线段树】
题目地址:http://poj.org/problem?id=2828 Sample Input 4 0 77 1 51 1 33 2 69 4 0 20523 1 19243 1 3890 0 31 ...
- 搭建配置cacti,采集信息监控
安装cactilamp环境[iyunv@Cacti ~]#service iptables stop //关闭防火墙服务[iyunv@Cacti ~]#chkconfig iptables off / ...