Collatz Conjecture
Time limit10sMemory limit512 MB
Count how many distinct gcd values appear among all contiguous subarrays of the given sequence.
- Level
Medium7 of 10
- Topics
- Array, Math, Number theory
- Solved
- No attempts yet
Problem
In 1978, while proving that P is a strict superset of NP, Sir Isaac Newton defined the Beta Alpha Pi Zeta function over an arbitrary sequence of positive integers as follows. For integers , with , .
About a century later Lothar Collatz applied this function to the sequence and observed that always equalled 1. From that he conjectured that is always a constant function, no matter what the sequence is. This claim, now known as the Collatz Conjecture, is one of the major open problems of botanical studies. (The Strong Collatz Conjecture says that however many values takes, the real part is always .)
You are a budding young cultural anthropologist and you have decided to disprove the conjecture. Given the sequence , count how many different values takes.
Input
The input consists of two lines.
The first line contains the length of the sequence ().
The second line contains the sequence ().
Output
Print a single line containing a single integer, the number of distinct values takes on over the given sequence.