結果

問題 No.1884 Sequence
ユーザー miscalcmiscalc
提出日時 2022-03-07 14:30:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 31,812 KB
最終ジャッジ日時 2023-09-29 15:20:59
合計ジャッジ時間 8,704 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,916 KB
testcase_01 AC 17 ms
8,024 KB
testcase_02 AC 16 ms
8,292 KB
testcase_03 AC 16 ms
8,220 KB
testcase_04 AC 16 ms
7,980 KB
testcase_05 AC 16 ms
8,248 KB
testcase_06 AC 16 ms
8,372 KB
testcase_07 AC 16 ms
7,928 KB
testcase_08 AC 16 ms
7,880 KB
testcase_09 AC 16 ms
8,240 KB
testcase_10 AC 358 ms
31,700 KB
testcase_11 AC 377 ms
31,700 KB
testcase_12 AC 57 ms
11,012 KB
testcase_13 AC 62 ms
11,124 KB
testcase_14 AC 60 ms
11,428 KB
testcase_15 AC 222 ms
20,568 KB
testcase_16 AC 373 ms
31,732 KB
testcase_17 AC 129 ms
19,476 KB
testcase_18 AC 188 ms
22,080 KB
testcase_19 AC 151 ms
18,928 KB
testcase_20 AC 180 ms
18,384 KB
testcase_21 AC 140 ms
16,864 KB
testcase_22 AC 199 ms
19,436 KB
testcase_23 AC 375 ms
30,016 KB
testcase_24 AC 381 ms
31,616 KB
testcase_25 AC 375 ms
30,012 KB
testcase_26 AC 374 ms
31,764 KB
testcase_27 AC 67 ms
11,996 KB
testcase_28 AC 68 ms
12,056 KB
testcase_29 AC 67 ms
12,016 KB
testcase_30 AC 67 ms
12,004 KB
testcase_31 AC 147 ms
18,460 KB
testcase_32 AC 267 ms
30,488 KB
testcase_33 AC 170 ms
31,744 KB
testcase_34 AC 173 ms
31,656 KB
testcase_35 AC 76 ms
13,912 KB
testcase_36 AC 136 ms
23,856 KB
testcase_37 AC 170 ms
31,812 KB
testcase_38 AC 167 ms
31,296 KB
testcase_39 AC 92 ms
17,264 KB
testcase_40 AC 99 ms
16,980 KB
testcase_41 AC 299 ms
26,296 KB
testcase_42 AC 302 ms
26,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys

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

c = []
for i in range(n):
  if a[i] != 0:
    c.append(a[i])
k = len(c)
if k == 0:
  print('Yes')
  sys.exit(0)

c = sorted(c)
d = []
for i in range(k - 1):
  d.append(c[i + 1] - c[i])

zerocnt = d.count(0)
if zerocnt > 0:
  print('Yes' if zerocnt == k - 1 else 'No')
  sys.exit(0)

g = 0
for i in range(k - 1):
  g = math.gcd(g, d[i])

need = 0
for i in range(k - 1):
  tmp = d[i] / g - 1
  need += tmp

print('Yes' if need <= n - k else 'No')
0