Periodic Strings

UVA - 455

题目传送门

题目大意:先输入一个数字n,在输入n行字符串,对每一个字符串输出其最小的周期长度,每两个输出间有一空行。

AC代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
char str[100];
int main()
{int n;while (scanf("%d",&n)!=EOF){while (n--) {scanf("%s",str);int len=strlen(str); rep(i,1,len) {int t=0;if (len%i==0){for (t=i;t<len;t++)if (str[t]!=str[t%i])break;if (t==len){printf("%d\n",i);break;}}}if(n)printf("\n");}}return 0;
}

UVA - 455 Periodic Strings【字符串】相关推荐

  1. 455 periodic strings

    这个题是求在一个没有空格的字符串中,最短的重复的语句的长度是多少 这个题也许用其他方法也能做出来,但我感觉做这个题所运用的思路非常好 #include<stdio.h> #include& ...

  2. Periodic Strings 字符串处理

    题目网址:https://vjudge.net/problem/UVA-455 简单的一道字符串处理的题目,这道题目历经波折.wa点主要在格式,和几个特例: asasasa 7 aaacaaacaaa ...

  3. UVa455 Periodic Strings(kmp)

    先计算字符串的前缀函数,字符串长度为n,如果,说明字符串是周期的,否则不是. 代码参考: OJ/Periodic Strings(kmp).java at master · wuli2496/OJ · ...

  4. UVA455 Periodic Strings

    问题链接:UVA455 Periodic Strings.入门练习题,用C语言编写程序. 题意:如果一个串可以由长度为k的字符串重复多次连接而得到,则称该串为k周期.本题求一个串的最小周期. 程序中, ...

  5. UVA455 Periodic Strings【水题】

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

  6. UVA455 - Periodic Strings(周期串)

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

  7. (循环串)Periodic Strings UVA - 455

    题目链接 题意 大致是找出一个字符串中的一个连续的最短的重复单位,就是找一个循环部分. 记录这题主要是想写那个循环串的思想, 题解: 一个长度为k的字符串,其周期必定在1~k,所以对于串中的每一个元素 ...

  8. [LeetCode] Isomorphic Strings - 字符串操作:数组计数字符个数问题

    题目概述: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the ...

  9. UVA455 - Periodic Strings

    原题链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=830& ...

最新文章

  1. 从Python到AI,这条路好走吗?
  2. C++__min_element()和max_element()函数的使用
  3. 3句话点评2020年看过的那些精彩的电影
  4. ABCpdf.NET 的简易使用指南
  5. 012_Vue计算属性
  6. 谷歌chrome浏览器的源码分析(六)
  7. Android Demos
  8. 【计网】计算机网络期末总复习-谢希仁(个人总结)理论概念
  9. 纪中B组模拟赛总结(2020.2.09)
  10. jax-rs jax-ws_您的JAX-RS API并非天生就等于:使用动态功能
  11. linux-文件路径
  12. 设计模式学习笔记——策略(Strategy)模式
  13. NGUI_Atlas
  14. 建筑CAD基础设计【2】
  15. quartz表删除顺序
  16. 特征放缩(Feature scaling)
  17. [附源码]java毕业设计校园快递管理系统
  18. android studio中添加EditText错误的解决方法
  19. 盘点 | 2023年最值得学的编程语言TOP 5,Python再度夺冠!
  20. Part1 コンビニエンス・ストア編(1)---基本的な業務を知る

热门文章

  1. java 实体类 代码重复_java – JPA两个单向@OneToMany关系到同一个实体导致重复输入...
  2. 鸿蒙os2.0开发者beta版,鸿蒙 OS 2.0 开发者beta版针对Mate 40系列设备开放
  3. wordcount.java_mapreduce中wordcount的java实现
  4. word论文排版插件_教你如何用word快速搞定论文排版
  5. 如何知道linux的ssh秘钥是否匹配,SSH密钥验证
  6. 二级c语言题型分数,计算机二级C语言题型和评分标准
  7. php收购,php中文网收购全国用户量最大的phpstudy集成开发环境揭秘
  8. 小米9android q测试版,基于Android Q的MIUI来了 小米9尝鲜
  9. jwt java 项目实例_JWT(JsonWebToken)+SpringMVC项目demo
  10. 在java继承机制中 父类中的私有_Java中子类能继承父类的私有属性吗?