結果

問題 No.1884 Sequence
ユーザー horitaka1999horitaka1999
提出日時 2022-03-25 22:27:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 1,234 bytes
コンパイル時間 417 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 133,904 KB
最終ジャッジ日時 2024-04-22 07:09:59
合計ジャッジ時間 7,133 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,352 KB
testcase_01 AC 40 ms
52,480 KB
testcase_02 AC 40 ms
52,480 KB
testcase_03 AC 41 ms
52,352 KB
testcase_04 AC 39 ms
52,480 KB
testcase_05 AC 40 ms
52,252 KB
testcase_06 AC 39 ms
52,352 KB
testcase_07 AC 41 ms
52,392 KB
testcase_08 AC 43 ms
52,352 KB
testcase_09 AC 40 ms
52,352 KB
testcase_10 AC 200 ms
133,660 KB
testcase_11 AC 197 ms
133,904 KB
testcase_12 AC 70 ms
89,472 KB
testcase_13 AC 73 ms
92,544 KB
testcase_14 AC 79 ms
94,208 KB
testcase_15 AC 141 ms
107,808 KB
testcase_16 AC 194 ms
133,096 KB
testcase_17 AC 109 ms
109,184 KB
testcase_18 AC 124 ms
107,520 KB
testcase_19 AC 112 ms
109,160 KB
testcase_20 AC 131 ms
106,752 KB
testcase_21 AC 112 ms
107,648 KB
testcase_22 AC 136 ms
106,624 KB
testcase_23 AC 195 ms
133,208 KB
testcase_24 AC 197 ms
133,296 KB
testcase_25 AC 195 ms
132,300 KB
testcase_26 AC 201 ms
133,896 KB
testcase_27 AC 76 ms
96,384 KB
testcase_28 AC 78 ms
97,280 KB
testcase_29 AC 79 ms
96,768 KB
testcase_30 AC 78 ms
97,280 KB
testcase_31 AC 119 ms
105,984 KB
testcase_32 AC 193 ms
131,376 KB
testcase_33 AC 134 ms
129,948 KB
testcase_34 AC 134 ms
129,432 KB
testcase_35 AC 84 ms
102,016 KB
testcase_36 AC 126 ms
114,136 KB
testcase_37 AC 139 ms
129,572 KB
testcase_38 AC 135 ms
129,724 KB
testcase_39 AC 97 ms
109,312 KB
testcase_40 AC 97 ms
108,304 KB
testcase_41 AC 176 ms
121,076 KB
testcase_42 AC 182 ms
120,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
from math import sqrt,ceil,floor
def yaku(n):#nの約数を列挙するO(sqrt(n))
    rev = []
    for i in range(1,ceil(sqrt(n))+1):
        if n % i == 0:
            rev.append(i)
            if n //i == i:
                continue
            rev.append(n//i)
    rev = list(set(rev))
    return sorted(rev)
N = int(input())
A = list(map(int,input().split()))
cnt = 0
def diff_list(List):
    rev = []
    for i in range(len(List)):
        if i + 1 < (len(List)):
            tmp = List[i+1] - List[i]
            rev.append(tmp)
    return rev
    
newA = []
for a in A:
    if a != 0:
        newA.append(a)
    else:
        cnt += 1
def is_ok(d):
    tmp = 0
    if d == 0:
        if max(newA) - min(newA) == 0:
            return True
        else:
            return False
    for di in dis:
        tmp += di // d - 1

    if tmp <= cnt:
        return True
    else:
        return False
if len(newA) <= 1:
    print('Yes')
else:
    newA.sort()
    dis = diff_list(newA)
    g = dis[0]
    for a in dis:
        if a == 0:
            g = 0
            break
        g = gcd(g,a)
    if is_ok(g):
        print('Yes')
        exit()

    print('No')
    
0