#C5822. Double Pattern Check
Double Pattern Check
Double Pattern Check
You are given a sequence of n integers. The goal is to determine whether the sequence forms a double pattern. A sequence has a double pattern if for every index i (2 ≤ i ≤ n), the i-th number is exactly twice the (i-1)-th number, i.e. it satisfies the relation:
\(a_i = 2 \times a_{i-1}\)
If the entire sequence follows this rule, output Yes
, otherwise output No
.
Input Format: The first line contains an integer n (n ≥ 2). The second line contains n integers separated by spaces.
Output Format: A single line containing either Yes
or No
.
inputFormat
The first line contains an integer n (n ≥ 2), which represents the number of integers in the sequence. The second line contains n space-separated integers representing the sequence.
outputFormat
Output a single line with Yes
if every integer (except the first) is double the previous one; otherwise, output No
.
4
2 4 8 16
Yes
</p>