Ultraviolet A 455-periodic strings

Source: Internet
Author: User

Question: Find the minimum cyclic section of a string.

Analysis: brute force, String. If the data volume is small, use the enumeration method directly.

Enumerate the length of the cyclic section, match and judge, find the first group of solutions to be the minimum.

Note: (⊙ _ ⊙ ).

# Include <iostream> # include <cstdlib> # include <cstring> # include <cstdio> using namespace STD; char STR [104]; int main () {int N; while (~ Scanf ("% d", & N) while (n --) {scanf ("% s", STR); int Len = strlen (STR); For (int K, I = 1; I <= Len; ++ I) if (LEN % I = 0) {for (k = I; k <Len; ++ K) if (STR [k]! = STR [K % I]) break; If (k = Len) {printf ("% d \ n", I); break ;}} if (N) printf ("\ n");} return 0 ;}


Ultraviolet A 455-periodic strings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.