#include <stdio.h>
#include <string.h>

int main()
{
    int T, k, len;
    char str[81], *p, *q, *end;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%s", str);
        len = strlen(str);
        end = str+len;
        for (k = 1; k < len; ++k)
        {
            p = str;
            q = str + k;
            while (p < end && q < end)
            {
                if (*p != *q)
                    break;
                ++p, ++q;
            }
            if (q == end)
            {
                q = str;
                while (p < end && q < end && *p++ == *q++);
                if (p == end)
                    break;
            }
        }

printf("%d\n", k);
        if (T) putchar('\n');
    }

return 0;
}

UVa455 Periodic Strings的更多相关文章

  1. UVA455 - Periodic Strings(紫书习题3.4)

    如果一个字符串可以被某个长度为k的字符串重复多次得到,则称这个字符串的周期为k.例如,字符串"abcabcabcabc"以3为周期(当然,他也以6.12等等为周期).  现在请你编 ...

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

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

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

  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. 周期串(Periodic Strings,UVa455)

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

  6. 周期串 (Periodic Strings,UVa455)

    #include<stdio.h> #include<string.h> int main(void) { int n,stlen,i,j; ]; while(scanf(&q ...

  7. 习题3-4 周期串(Periodic Strings, UVa455)

    #include<stdio.h> #include<string.h> char s[100]; int main() { int T; scanf("%d&quo ...

  8. UVa455 Periodic String 的wronganswer问题探讨,以及AC的新思路

    题目的意思是一个字符串有某个长度为k的字符串通过不断重复形成的,而k被称为该字符串的周期.而我们所要做的是找出该字符串的最小周期. input The first line is an integer ...

  9. UVa 455 Periodic Strings

    题意:给出一个字符串,找出它的最小的周期,枚举从1到len的周期,看是否满足. #include<iostream> #include<cstdio> #include< ...

随机推荐

  1. Android XListView实现原理讲解及分析

    XListview是一个非常受欢迎的下拉刷新控件,但是已经停止维护了.之前写过一篇XListview的使用介绍,用起来非常简单,这两天放假无聊,研究了下XListview的实现原理,学到了很多,今天分 ...

  2. 你会用shuffle打乱列表吗?

    在网站上我们经常会看到关键字云(Word Cloud)和标签云(Tag Cloud),用于表明这个关键字或标签是经常被查阅的,而且还可以看到这些标签的动态运动,每次刷新都会有不一样的关键字或便签,让浏 ...

  3. CentOS7 vs centos6

    The CentOS Project has announced general availability of CentOS-7, the first release of the free Lin ...

  4. ldap for ruby

    Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Acc ...

  5. openStack use

    <1,project security> security groyps Security groups--> are sets of IP filter rules() that ...

  6. spoj 7258 Lexicographical Substring Search (后缀自动机)

    spoj 7258 Lexicographical Substring Search (后缀自动机) 题意:给出一个字符串,长度为90000.询问q次,每次回答一个k,求字典序第k小的子串. 解题思路 ...

  7. background-size:的认识;

    background-size:100%;其实是元素的背景图片的宽度和元素宽度相同,高度auto: 也可理解为:background-size:100% auto; 而background:cover ...

  8. Hotel(线段树合并)

    Hotel Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 14958   Accepted: 6450 Descriptio ...

  9. sql获取表字段名、描述和类型

    SELECT TableName = OBJECT_NAME(c.object_id), ColumnsName = c.name, Description = ex.value, ColumnTyp ...

  10. oracle rac 安装脚本

    1. 配置/etc/hosts 网络 192.168.1.111 rac1 rac1.oracle.com192.168.1.182 rac1-vip 192.168.1.222 rac2 rac2. ...