結果

問題 No.1884 Sequence
ユーザー horitaka1999horitaka1999
提出日時 2022-03-25 22:11:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,278 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 134,044 KB
最終ジャッジ日時 2024-04-22 06:51:27
合計ジャッジ時間 13,650 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,352 KB
testcase_01 AC 35 ms
52,096 KB
testcase_02 AC 36 ms
52,224 KB
testcase_03 AC 35 ms
52,352 KB
testcase_04 AC 35 ms
52,352 KB
testcase_05 AC 36 ms
52,096 KB
testcase_06 AC 37 ms
52,352 KB
testcase_07 AC 314 ms
78,976 KB
testcase_08 AC 37 ms
52,480 KB
testcase_09 WA -
testcase_10 AC 193 ms
133,452 KB
testcase_11 AC 183 ms
133,880 KB
testcase_12 AC 72 ms
89,472 KB
testcase_13 AC 78 ms
93,184 KB
testcase_14 AC 81 ms
94,976 KB
testcase_15 AC 151 ms
107,264 KB
testcase_16 AC 193 ms
133,604 KB
testcase_17 AC 145 ms
109,312 KB
testcase_18 AC 123 ms
107,392 KB
testcase_19 AC 118 ms
108,928 KB
testcase_20 AC 135 ms
106,240 KB
testcase_21 AC 118 ms
108,032 KB
testcase_22 AC 139 ms
106,624 KB
testcase_23 AC 189 ms
133,452 KB
testcase_24 AC 224 ms
134,044 KB
testcase_25 AC 226 ms
132,428 KB
testcase_26 AC 199 ms
133,640 KB
testcase_27 AC 74 ms
96,256 KB
testcase_28 AC 75 ms
97,536 KB
testcase_29 AC 228 ms
97,664 KB
testcase_30 AC 76 ms
97,024 KB
testcase_31 AC 136 ms
106,624 KB
testcase_32 WA -
testcase_33 AC 128 ms
129,820 KB
testcase_34 AC 131 ms
129,940 KB
testcase_35 AC 86 ms
102,656 KB
testcase_36 AC 127 ms
114,656 KB
testcase_37 AC 136 ms
130,320 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 TLE -
testcase_42 TLE -
権限があれば一括ダウンロードができます

ソースコード

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:
        g = gcd(g,a)
    if is_ok(0):
        print('Yes')
        exit()

    ds = yaku(g)
    for d in ds:
        if is_ok(d):
            print('Yes')
            exit()
    print('No')
    
0