# UVA Solution 455 – Periodic Strings – UVA Periodic string solution

### UVA Solution 455 – Periodic Strings – UVA Periodic string solution

UVA Online Judge Solution 455 – Periodic Strings | Volume 4
UVA Problem Link – 455 – Periodic Strings

Problem Name: 455 – Periodic Strings solution
Problem Number : UVA – 455 – Periodic Strings
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C,C plus plus

### UVA Solution 455 – Periodic Strings Code in C/CPP:

`#include<stdio.h>#include<string.h>#define MaxL 1000int KMP_init(char *A) { int i, j; int P[MaxL]; P[0] = -1, i = 1, j = -1; while(A[i]) {  while(j >= 0 && A[j+1] != A[i])   j = P[j];  if(A[j+1] == A[i])   ++j;  P[i] = j, ++i; } return j;}int main() { int T; char s[MaxL]; scanf("%d", &T); while(T--) {  scanf("%s", s);  int l = strlen(s), t = KMP_init(s);  if(l%(l-t-1))   printf("%dn", l);  else   printf("%dn", l-t-1);  if(T) puts(""); }    return 0;}`

Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list, UVA Periodic Strings  code in C, UVA 455  code in C++, UVA 455 – Periodic Strings  solution in C, UVA Periodic Strings solution

#### By Maniruzzaman Akash

Maniruzzaman Akash is a freelance web developer with most popular Laravel PHP frameork and Vue JS