結果

問題 No.1884 Sequence
ユーザー horitaka1999horitaka1999
提出日時 2022-03-25 22:07:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,220 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 133,992 KB
最終ジャッジ日時 2024-04-22 06:48:50
合計ジャッジ時間 11,882 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
57,856 KB
testcase_01 AC 38 ms
52,352 KB
testcase_02 AC 39 ms
51,968 KB
testcase_03 AC 37 ms
52,608 KB
testcase_04 AC 38 ms
52,324 KB
testcase_05 AC 38 ms
52,352 KB
testcase_06 AC 38 ms
52,096 KB
testcase_07 AC 297 ms
79,340 KB
testcase_08 AC 36 ms
52,352 KB
testcase_09 WA -
testcase_10 AC 191 ms
133,788 KB
testcase_11 AC 184 ms
133,788 KB
testcase_12 AC 71 ms
89,728 KB
testcase_13 AC 73 ms
93,056 KB
testcase_14 AC 80 ms
95,744 KB
testcase_15 AC 147 ms
107,676 KB
testcase_16 AC 192 ms
133,596 KB
testcase_17 AC 147 ms
109,568 KB
testcase_18 AC 121 ms
107,392 KB
testcase_19 AC 119 ms
109,056 KB
testcase_20 AC 133 ms
106,240 KB
testcase_21 AC 112 ms
108,160 KB
testcase_22 AC 140 ms
107,300 KB
testcase_23 AC 199 ms
133,720 KB
testcase_24 AC 233 ms
133,992 KB
testcase_25 AC 235 ms
132,252 KB
testcase_26 AC 203 ms
133,388 KB
testcase_27 AC 73 ms
96,896 KB
testcase_28 AC 77 ms
97,024 KB
testcase_29 AC 233 ms
97,792 KB
testcase_30 AC 76 ms
97,408 KB
testcase_31 AC 139 ms
106,112 KB
testcase_32 WA -
testcase_33 AC 130 ms
130,080 KB
testcase_34 AC 130 ms
130,332 KB
testcase_35 AC 83 ms
102,016 KB
testcase_36 AC 118 ms
114,592 KB
testcase_37 AC 138 ms
129,568 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 is_ok(0):
        print('Yes')
        exit()

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