結果

問題 No.1884 Sequence
ユーザー horitaka1999horitaka1999
提出日時 2022-03-25 21:58:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,154 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 133,868 KB
最終ジャッジ日時 2024-04-22 06:39:20
合計ジャッジ時間 12,434 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,352 KB
testcase_01 AC 38 ms
52,480 KB
testcase_02 AC 37 ms
52,096 KB
testcase_03 AC 37 ms
52,096 KB
testcase_04 AC 37 ms
52,480 KB
testcase_05 AC 37 ms
52,352 KB
testcase_06 AC 37 ms
51,968 KB
testcase_07 AC 301 ms
79,232 KB
testcase_08 AC 38 ms
52,224 KB
testcase_09 WA -
testcase_10 AC 183 ms
133,348 KB
testcase_11 AC 183 ms
133,476 KB
testcase_12 AC 69 ms
89,856 KB
testcase_13 AC 72 ms
93,312 KB
testcase_14 AC 78 ms
94,592 KB
testcase_15 AC 160 ms
107,648 KB
testcase_16 AC 192 ms
133,868 KB
testcase_17 AC 152 ms
109,824 KB
testcase_18 AC 127 ms
107,392 KB
testcase_19 AC 119 ms
108,928 KB
testcase_20 AC 138 ms
106,368 KB
testcase_21 AC 122 ms
107,904 KB
testcase_22 AC 142 ms
107,008 KB
testcase_23 AC 201 ms
133,352 KB
testcase_24 AC 227 ms
133,492 KB
testcase_25 AC 221 ms
132,316 KB
testcase_26 AC 200 ms
133,764 KB
testcase_27 AC 76 ms
96,896 KB
testcase_28 AC 76 ms
96,896 KB
testcase_29 AC 233 ms
97,536 KB
testcase_30 AC 77 ms
97,280 KB
testcase_31 AC 139 ms
106,496 KB
testcase_32 WA -
testcase_33 AC 128 ms
130,096 KB
testcase_34 AC 132 ms
129,716 KB
testcase_35 AC 85 ms
101,888 KB
testcase_36 AC 128 ms
114,384 KB
testcase_37 AC 135 ms
129,960 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
newA.sort()
def is_ok(d):
    tmp = 0
    for di in dis:
        tmp += di // d - 1

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