結果

問題 No.1884 Sequence
ユーザー horitaka1999horitaka1999
提出日時 2022-03-25 22:01:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,309 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 133,980 KB
最終ジャッジ日時 2024-04-22 06:42:28
合計ジャッジ時間 12,414 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
58,112 KB
testcase_01 AC 41 ms
52,352 KB
testcase_02 AC 41 ms
52,224 KB
testcase_03 AC 40 ms
52,224 KB
testcase_04 AC 41 ms
51,968 KB
testcase_05 AC 40 ms
52,096 KB
testcase_06 AC 42 ms
52,352 KB
testcase_07 AC 327 ms
79,360 KB
testcase_08 AC 40 ms
52,352 KB
testcase_09 WA -
testcase_10 AC 205 ms
133,700 KB
testcase_11 AC 205 ms
133,576 KB
testcase_12 AC 79 ms
89,728 KB
testcase_13 AC 85 ms
93,056 KB
testcase_14 AC 89 ms
94,592 KB
testcase_15 AC 163 ms
107,648 KB
testcase_16 AC 216 ms
133,540 KB
testcase_17 AC 158 ms
109,312 KB
testcase_18 AC 138 ms
108,032 KB
testcase_19 AC 133 ms
108,800 KB
testcase_20 AC 153 ms
106,496 KB
testcase_21 AC 129 ms
108,032 KB
testcase_22 AC 156 ms
106,752 KB
testcase_23 AC 215 ms
133,328 KB
testcase_24 AC 251 ms
133,980 KB
testcase_25 AC 251 ms
132,292 KB
testcase_26 AC 221 ms
133,756 KB
testcase_27 AC 83 ms
96,640 KB
testcase_28 AC 85 ms
96,896 KB
testcase_29 AC 256 ms
97,280 KB
testcase_30 AC 90 ms
97,408 KB
testcase_31 AC 155 ms
106,240 KB
testcase_32 WA -
testcase_33 AC 143 ms
129,936 KB
testcase_34 AC 145 ms
130,192 KB
testcase_35 AC 96 ms
102,528 KB
testcase_36 AC 135 ms
114,744 KB
testcase_37 AC 157 ms
130,328 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 TLE -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

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:
        if d == 0:
            tmp += max(di-1,0)
        else:
            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:
        if is_ok(g):
            print('Yes')
            exit()
        else:
            print('No')
            exit()

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