#C9983. Unique Necklaces
Unique Necklaces
Unique Necklaces
Given a necklace represented as a string t
consisting of lowercase English letters, determine the number of unique necklaces that can be obtained by cyclically rotating the string. A rotation is defined as taking some prefix of the string and moving it to the end. Two rotations are considered the same if they yield identical strings.
Formally, for a string \( t \) of length \( n \), for each \( i \) (\( 0 \leq i < n \)), let \( t_i = t[i:] + t[:i] \). The task is to compute the number of distinct strings among \( \{ t_0, t_1, \ldots, t_{n-1} \} \).
Input Constraints: The string \( t \) is non-empty and consists only of lowercase English letters.
Example:
For \( t = \texttt{mnmn} \), its rotations are \( "mnmn", "nmnm", "mnmn", "nmnm" \), yielding 2 unique necklaces.
inputFormat
The input is read from standard input (stdin) and consists of a single line containing the string \( t \), which represents the necklace.
outputFormat
The output is a single integer printed on standard output (stdout) representing the number of unique necklaces that can be formed by rotating the input string.
## samplemnmn
2