結果

問題 No.1884 Sequence
ユーザー 👑 rin204
提出日時 2022-03-25 21:24:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 182,232 KB
最終ジャッジ日時 2024-10-14 05:12:47
合計ジャッジ時間 7,094 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

n = int(input())
A = list(map(int, input().split()))

B = []
zero = 0
for a in A:
    if a != 0:
        B.append(a)
    else:
        zero += 1
if zero >= n - 1:
    print("Yes")
    exit()
if len(set(B)) == 1:
    print("Yes")
    exit()
B.sort()
b0 = B[0]
g = 0
for i, b in enumerate(B):
    B[i] -= b0
    g = gcd(g, b - b0)

B = [b // g for b in B]
if len(set(B)) == len(B) and B[-1] < n:
    print("Yes")
else:
    print("No")
0