CF745A.Hongcow Learns the Cyclic Shift

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.

Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.

Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.

洪可牛正在学习拼写!一天,他的老师给了他一个需要学习拼写的单词。作为一名认真负责的学生,他立刻学会了如何拼写这个单词。

洪可牛决定尝试从这个单词出发构造出新的单词。他首先取来刚刚学会拼写的那个单词,然后将该单词的最后一个字符移到最前面,他把这种操作称为循环移位(cyclic shift)。他可以对单词执行任意多次循环移位操作。例如,对单词 "abracadabra" 连续执行循环移位操作,洪可牛将依次得到 "aabracadabr"、"raabracadab" 等等。

现在,洪可牛想知道:通过任意多次循环移位操作,他最多能生成多少个互不相同的单词?(原始字符串本身也计入总数。)

输入格式

The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').

输入的第一行是一个字符串 ss(1 ≤ ∣s∣ ≤ 501 \le |s| \le 50),表示 Hongcow 最初学会拼写的单词。字符串 ss 仅由小写英文字母('a'–'z')组成。

输出格式

Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.

输出一个整数,表示 Hongcow 通过对给定字符串进行任意次数的循环移位所能得到的不同字符串的个数。

输入输出样例

  • 输入#1

    abcd

    输出#1

    4
  • 输入#2

    bbb

    输出#2

    1
  • 输入#3

    yzyz

    输出#3

    2

说明/提示

For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".

For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".

For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".

对于第一个样例,Hongcow 可以生成的字符串有 “abcd”、“dabc”、“cdab” 和 “bcda”。

对于第二个样例,无论 Hongcow 进行多少次循环移位,都只能生成字符串 “bbb”。

对于第三个样例,Hongcow 可以生成的两个字符串是 “yzyz” 和 “zyzy”。

输入解题思路,AI测评打分。不知道怎么写?

首页