

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
長さ N の正整数列 A=(A_1,A_2,\ldots,A_N) が与えられます。
A が等比数列であるか判定してください。
制約
- 2\leq N\leq 100
- 1\leq A_i\leq 10^9
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
出力
A が 等比数列ならば Yes
を、そうでないならば No
を出力せよ。
入力例 1
5 3 6 12 24 48
出力例 1
Yes
A=(3,6,12,24,48) です。
A は初項 3, 公比 2, 項数 5 の等比数列となっています。
よって、Yes
を出力します。
入力例 2
3 1 2 3
出力例 2
No
A=(1,2,3) です。
A_1:A_2=1:2\neq 2:3=A_2:A_3 より、A は等比数列ではありません。
よって、No
を出力します。
入力例 3
2 10 8
出力例 3
Yes
A は初項 10, 公比 0.8, 項数 2 の等比数列となっています。
よって、Yes
を出力します。
Score : 200 points
Problem Statement
You are given a length-N sequence A=(A_1,A_2,\ldots,A_N) of positive integers.
Determine whether A is a geometric progression.
Constraints
- 2 \leq N \leq 100
- 1 \leq A_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_N
Output
If A is a geometric progression, print Yes
; otherwise, print No
.
Sample Input 1
5 3 6 12 24 48
Sample Output 1
Yes
A=(3,6,12,24,48).
A is a geometric progression with first term 3, common ratio 2, and five terms.
Therefore, print Yes
.
Sample Input 2
3 1 2 3
Sample Output 2
No
A=(1,2,3).
Since A_1 : A_2 = 1 : 2 \neq 2 : 3 = A_2 : A_3, A is not a geometric progression.
Therefore, print No
.
Sample Input 3
2 10 8
Sample Output 3
Yes
A is a geometric progression with first term 10, common ratio 0.8, and two terms.
Therefore, print Yes
.