結果

問題 No.1884 Sequence
ユーザー hir355hir355
提出日時 2022-03-25 21:34:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 118,544 KB
最終ジャッジ日時 2024-04-22 06:13:17
合計ジャッジ時間 6,092 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,712 KB
testcase_01 AC 38 ms
52,352 KB
testcase_02 AC 38 ms
52,096 KB
testcase_03 AC 38 ms
51,968 KB
testcase_04 AC 37 ms
52,096 KB
testcase_05 AC 37 ms
51,968 KB
testcase_06 AC 37 ms
51,584 KB
testcase_07 AC 38 ms
51,840 KB
testcase_08 AC 38 ms
51,584 KB
testcase_09 AC 38 ms
51,584 KB
testcase_10 AC 185 ms
117,960 KB
testcase_11 AC 187 ms
118,012 KB
testcase_12 AC 68 ms
89,216 KB
testcase_13 AC 71 ms
92,288 KB
testcase_14 AC 71 ms
90,752 KB
testcase_15 AC 118 ms
107,648 KB
testcase_16 AC 154 ms
117,640 KB
testcase_17 AC 89 ms
108,544 KB
testcase_18 AC 100 ms
107,520 KB
testcase_19 AC 96 ms
109,056 KB
testcase_20 AC 110 ms
106,496 KB
testcase_21 AC 96 ms
105,984 KB
testcase_22 AC 116 ms
107,000 KB
testcase_23 AC 155 ms
118,096 KB
testcase_24 AC 156 ms
118,544 KB
testcase_25 AC 156 ms
117,120 KB
testcase_26 AC 155 ms
118,392 KB
testcase_27 AC 74 ms
96,640 KB
testcase_28 AC 76 ms
97,408 KB
testcase_29 AC 77 ms
97,408 KB
testcase_30 AC 77 ms
97,152 KB
testcase_31 AC 108 ms
106,240 KB
testcase_32 AC 153 ms
116,940 KB
testcase_33 AC 114 ms
116,112 KB
testcase_34 AC 113 ms
116,552 KB
testcase_35 AC 78 ms
98,944 KB
testcase_36 AC 112 ms
106,256 KB
testcase_37 AC 118 ms
116,160 KB
testcase_38 AC 115 ms
114,404 KB
testcase_39 AC 85 ms
104,064 KB
testcase_40 AC 86 ms
105,472 KB
testcase_41 AC 143 ms
110,608 KB
testcase_42 AC 140 ms
109,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
n = int(input())
a = list(map(int, input().split()))
b = []
cnt = 0
for x in a:
    if x == 0:
        cnt += 1
    else:
        b.append(x)
b.sort()
if len(b) <= 1:
    print('Yes')
else:
    g = b[1] - b[0]
    for i in range(len(b) - 1):
        if b[i + 1] - b[i] == 0:
            g = 0
            break
        else:
            g = gcd(g, b[i + 1] - b[i])
    if g == 0:
        if b[-1] - b[0] == 0:
            print('Yes')
        else:
            print('No')
    elif (b[-1] - b[0]) // g + 1 - len(b) <= cnt:
        print('Yes')
    else:
        print('No')
0