UVA.455 Periodic Strings(字符串的最小周期)
Periodic Strings
模板
题意分析
判断字符串的最小周期
代码总览
/*
Title:UVA.455
Author:pengwill
Date:2016-12-16
*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char str[100];
int main()
{
int n;
scanf("%d",&n);
while(n--){
scanf(" %s",str);
int len = strlen(str);
int i,j;
for(i = 1;i<=len;i++){
if(len%i == 0){
for(j = 0;j<len;j++){
if(str[j] !=str[j%i]){break;}
}
if(j == len){
printf("%d\n",i);
break;
}
}
}
if(n){printf("\n");}
}
return 0;
}
UVA.455 Periodic Strings(字符串的最小周期)的更多相关文章
- UVa 455 - Periodic Strings解题报告
UVa OJ 455 Periodic Strings A character string is said to have period k if it can be formed by conca ...
- UVa 455 - Periodic Strings - ( C++ ) - 解题报告
1.题目大意 求一个长度不超过80的字符串的最小周期. 2.思路 非常简单,基本就是根据周期的定义做出来的,几乎不需要过脑. 3.应该注意的地方 (1) 最后输出的方式要注意,不然很容易就PE了.不过 ...
- UVa 455 Periodic Strings
题意:给出一个字符串,找出它的最小的周期,枚举从1到len的周期,看是否满足. #include<iostream> #include<cstdio> #include< ...
- UVa OJ 455 Periodic Strings
Periodic Strings A character string is said to have period k if it can be formed by concatenating ...
- UVA 10298 Power Strings 字符串的幂(KMP,最小循环节)
题意: 定义a为一个字符串,a*a表示两个字符相连,即 an+1=a*an ,也就是出现循环了.给定一个字符串,若将其表示成an,问n最大为多少? 思路: 如果完全不循环,顶多就是类似于abc1这样, ...
- POJ--2406Power Strings+KMP求字符串最小周期
题目链接:点击进入 事实上就是KMP算法next数组的简单应用.假设我们设这个字符串的最小周期为x 长度为len,那么由next数组的意义,我们知道len-next[len]的值就会等于x.这就是这个 ...
- E - Power Strings,求最小周期串
E - Power Strings Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u S ...
- UVA455 - Periodic Strings(紫书习题3.4)
如果一个字符串可以被某个长度为k的字符串重复多次得到,则称这个字符串的周期为k.例如,字符串"abcabcabcabc"以3为周期(当然,他也以6.12等等为周期). 现在请你编 ...
- UVA 455(最小周期)
最小周期可以用%枚举 #include <iostream> #include <string> #include <cstring> #include <c ...
随机推荐
- UPA深度性能报告解读
WeTest 导读 UPA作为腾讯WeTest与Unity官方联合打造的客户端性能分析工具,为开发者提供了极大的便利和效能提升.产出的分析报告内容详尽,但您是否真的读懂了报告?是否了解每项数据的含义? ...
- vuecli结合eslint静态检查
vuecli结合eslint静态检查 搭建vue项目开发可能选择vue-cli项目脚手架快速创建vue项目.(https://github.com/vuejs/vue-cli) 安装vue-cli n ...
- 你需要掌握的http知识
作为一名前端er,http是我们必须要掌握的,那么我们到底需要掌握哪些东西呢 一.基础知识 这里我们介绍与http相关的TCP.IP.DNS.url.uri 1.IP IP地址是我们很熟悉的东西,最常 ...
- TPO-15 C1 The campus newspaper's reporter position
TPO-15 C1 The campus newspaper's reporter position 第 1 段 1.Listen to a conversation between a Studen ...
- crt0.S(_main)代码分析
crt0,S(_main)代码分析 --- 1. 设置sp寄存器地址 //设置SP栈指针 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG ...
- java.net.ProtocolException: Server redirected too many times
网页爬虫时,原来正常的代码,可能是因为网站做了cookie校验处理,报异常:java.net.ProtocolException: Server redirected too many times 表 ...
- NSValue的valueWithBytes:objCType:方法
+ (NSValue *)valueWithBytes:(const void *)value objCType:(const char *)type; NSValue的valueWithBytes: ...
- 使用libpcab抓包&处理包
#include <stdio.h> #include <stdlib.h> #include <strings.h> #include <string.h& ...
- 条款03 尽可能使用const
一.概述 使用const约束对象:可以获得编译器的帮助(指出相关出错的地方) const与成员函数:const重载.转型.避免代码重复 二.细节 1. 为什么有些函数要返回const对象(看上去没必要 ...
- Thunder团队第三周 - Scrum会议6
Scrum会议6 小组名称:Thunder 项目名称:i阅app Scrum Master:宋雨 工作照片: 代秋彤照相,所以图片中没有该同学. 参会成员: 王航:http://www.cnblogs ...