Geometric or Not
Is the integer sequence a geometric progression (each term the previous times a fixed ratio)? The ratio need not be an integer conceptually, but all TERMS are integers.
Input: the first line has N; the second line has N integers.
Output: YES or NO (length ≤ 2 is YES).
Constraints:
- 1 ≤ N ≤ 60
- |terms| ≤ 1018
Sample Tests
Input 1
4 2 6 18 54
Output 1
YES
Input 2
3 1 2 3
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.