最小周期可以用%枚举

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <cctype>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long int main()
{
char str[];
sf("%s",str);
int n = strlen(str);
int k,i;
for(i=;i<n;i++)
{
for(k=i;k<n;k++)
{
if(str[k]!=str[k%i])
break;
}
if(k==n)
{
pf("%d\n",i);
break;
}
} }

UVA 455(最小周期)的更多相关文章

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

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

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

  3. E - Power Strings,求最小周期串

    E - Power Strings Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u S ...

  4. POJ--2406Power Strings+KMP求字符串最小周期

    题目链接:点击进入 事实上就是KMP算法next数组的简单应用.假设我们设这个字符串的最小周期为x 长度为len,那么由next数组的意义,我们知道len-next[len]的值就会等于x.这就是这个 ...

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

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

  6. 【KMP求最小周期】POJ2406-Power Strings

    [题意] 给出一个字符串,求出最小周期. [思路] 对KMP的next数组的理解与运用orz ①证明:如果最小周期不等于它本身,则前缀和后缀必定有交叉. 如果没有交叉,以当前的next[n]为最小周期 ...

  7. UVa455 最小周期串问题

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

  8. UVa 455 Periodic Strings

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

  9. SAM I AM UVA - 11419 最小点集覆盖 要输出具体覆盖的行和列。

    /** 题目:SAM I AM UVA - 11419 链接:https://vjudge.net/problem/UVA-11419 题意:给定n*n的矩阵,'X'表示障碍物,'.'表示空格;你有一 ...

随机推荐

  1. 【JVM】jvm启动参数

    -server -Xmx2048m -Xms1500m -Xmn1024m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConc ...

  2. AssertJ断言系列<一>

    1 - Get AssertJ Core assertions Maven的pom.xml加入如下配置: <dependency> <groupId>org.assertj&l ...

  3. leetcode-78-子集(用bfs解决)

    题目描述: 给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集). 说明:解集不能包含重复的子集. 示例: 输入: nums = [1,2,3] 输出: [ [3],   [1] ...

  4. Python:学习遇到的小问题:记事本写的脚本执行提示SystaxError:(unicode error) 'utf-8'

    学习了一段时间的Python因为懒没有坚持,现在又想学,在用记事本写好py脚本运行时报错:SystaxError:(unicode error) 'utf-8' 解决的方法: 因为我的笔记本系统自带的 ...

  5. 初识Flask框架,以及Flask中的模板语言jinjia2和Flask内置的Session

    一.web框架的对比 首先我们先来看下比较火的web框架 1.Django: 优点:大而全,所有组件都是组织内部开发高度定制化,教科书级别的框架 缺点:大到浪费资源,请求的时候需要的资源较高 2.Fl ...

  6. dp--最大区间和变形-cf-1155D

    dp--最大区间和变形-cf-1155D D. Beautiful Array time limit per test 2 seconds memory limit per test 256 mega ...

  7. Alfred修改内置Terminal为iTerm

    用这个脚本: on write_to_file(this_data, target_file, append_data) try set the target_file to the target_f ...

  8. Linux安装phpMywind

    1.安装MySQL http://www.cnblogs.com/wangshuyi/p/6091244.html 2.安装apache.php.及其扩展 yum install -y httpd p ...

  9. Elastic-Job源码分析之JobScheduler类分析

    JobScheduler这个类是EJ中比较核心的一个类,我们现在开始解析这个类. 一.构造器 首先我们看一下JobScheduler的几个构造器. private JobScheduler(final ...

  10. python-fork聊天室

    服务端 #!/usr/bin/python from socket import * import sys import os class Node(object): def __init__(sel ...