题意:给出一个字符串,找出它的最小的周期,枚举从1到len的周期,看是否满足。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; char s[]; int main()
{
int ncase,t,i,k,j,len;
scanf("%d",&ncase);
while(ncase--)
{
scanf("%s",s);len=strlen(s); for(t=;t<len;t++)//枚举周期从1到len1来找最小的循环节
{
if(len%t) continue;//如果不能整除的话就不是周期
int flag=;
for(j=,k=;j<len;k=k%t)
if(s[j++]!=s[k++]) flag=; if(flag) break;
} printf("%d\n",t);
if(ncase!=) printf("\n");
}
}

UVa 455 Periodic Strings的更多相关文章

  1. 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 ...

  2. UVA.455 Periodic Strings(字符串的最小周期)

    Periodic Strings 模板 题意分析 判断字符串的最小周期 代码总览 /* Title:UVA.455 Author:pengwill Date:2016-12-16 */ #includ ...

  3. UVa 455 - Periodic Strings - ( C++ ) - 解题报告

    1.题目大意 求一个长度不超过80的字符串的最小周期. 2.思路 非常简单,基本就是根据周期的定义做出来的,几乎不需要过脑. 3.应该注意的地方 (1) 最后输出的方式要注意,不然很容易就PE了.不过 ...

  4. UVa OJ 455 Periodic Strings

     Periodic Strings  A character string is said to have period k if it can be formed by concatenating ...

  5. 【习题 3-4 UVA - 455】Periodic Strings

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举 [代码] #include <bits/stdc++.h> using namespace std; const ...

  6. Periodic Strings UVA - 455

    ​ A character string is said to have period k if it can be formed by concatenating one or more repet ...

  7. UVA - 10298 Power Strings (KMP求字符串循环节)

    Description Problem D: Power Strings Given two strings a and b we define a*b to be their concatenati ...

  8. 周期串(Periodic Strings,UVa455)

    解题思路: 对一个字符串求其最小周期长度,那么,最小周期长度必定是字符串长度的约数,即最小周期长度必定能被字符串长度整除 其次,对于最小周期字符串,每位都能对应其后周期字串的每一位, 即 ABC  A ...

  9. UVA 10298 Power Strings 字符串的幂(KMP,最小循环节)

    题意: 定义a为一个字符串,a*a表示两个字符相连,即 an+1=a*an ,也就是出现循环了.给定一个字符串,若将其表示成an,问n最大为多少? 思路: 如果完全不循环,顶多就是类似于abc1这样, ...

随机推荐

  1. ZOJ3724 Delivery(树状数组??)

    题意:给你一个有向图,第一类边是从第i个点到第i+1个点的,还有多出来的m条二类边,是从u到v的,同样是有向的.然后你要处理询问,从u到v经过最多一次二类边的最短距离是多少. 题目我觉得是神题,然后看 ...

  2. 【Spark】概述

    大数据数据处理模型: 1.Google的MapReduce是一个简单通用和自动容错的批处理计算模型.但,不适合交互式和流式计算! 2.Storm 3.Impala 4.GraphLab 5.Spark ...

  3. BroadcastReceiver应用1

    有两种注册方式:1. 在AndroidManifest中注册.2. 在代码中直接注册,这种注册需要注意的一点是:当注册此Receiver的Activity退出的时候,一定要调用unregisterRe ...

  4. hdu 4068 SanguoSHA

    搜索下就可以了…… 代码如下: #include<iostream> #include<cstring> #include<cstdio> #include< ...

  5. 网站建设底层知识Socket与Http解析

    在进行网站建设的时候,常常遇到不同的协议,Socket和http协议都可以实现数据传输,但两种传输方式在网站建设中有什么各自的特点,和缺点,如何选择合适的传输方式. 1 数据传输方式 1.1  Soc ...

  6. nil和NULL

  7. ffmpeg转码时对编码率和固定码率的处理

    http://www.rosoo.net/a/201107/14663.html 一般fps在代码里这样表示 Fps = den/num 如果den = 15,num=1,则fps = 15. 如果帧 ...

  8. 4 tips for staying productive on Friday

    4 tips for staying productive on Friday如何让你的周五和周一一样有效率1.Schedule Your Day with Tasks 用任务计划一天 Sometim ...

  9. JAVA编译异常处理:java.lang.OutOfMemoryError: PermGen space

    在Intellij开发工具中编译JAVA项目,出现以下错误: 六月 21, 2016 6:28:07 下午 org.apache.tomcat.util.modeler.BaseModelMBean ...

  10. MAVEN ERROR: unable to find valid certification path to requested target 解决办法

    第一次使用MAVEN编译项目,出现如下错误 解决办法:Maven的setting.xml中添加如下代码 <mirrors> <mirror> <id>Central ...