CBOJ Winter Contest Problem 1 - Cyclic Isomers
Bob is learning organic chemistry!
One recent concept Bob learned is how molecules can rotate in 3D space and retain its properties. He wants to apply this to some arrays now:
You are given an array with \(N\) integers. The array can be rotated to the right by moving the last element to the front, and this can be done as many times as Bob wants. How many distinct arrays can you make?
Two arrays are said to be identical if each element's value when read from left to right is the same.
Please help Bob find the answer!
The first line contains an integer \(N\) \((1 \le N \le 100)\), representing the number of elements in the array.
The next line contains \(N\) integers with values ranging from \(0\) to \(10^6\), describing Bob's array.
Output an integer, indicating the number of distinct arrays Bob can make by rotating his array.
4 1 2 1 2
There are two distinct arrays Bob can make:
- \([1, 2, 1, 2]\), which is formed with the initial array,
- \([2, 1, 2, 1]\), which is formed by rotating either 1 or 3 times to the right.