Problems > Geometric or Not

Geometric or Not

Difficulty: 1300 2000 ms 128 MB

math

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

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.