結果

問題 No.1884 Sequence
ユーザー horitaka1999horitaka1999
提出日時 2022-03-25 21:49:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 119,060 KB
最終ジャッジ日時 2024-04-22 06:29:31
合計ジャッジ時間 7,538 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,096 KB
testcase_01 AC 39 ms
52,608 KB
testcase_02 AC 37 ms
52,096 KB
testcase_03 AC 38 ms
52,352 KB
testcase_04 AC 38 ms
52,352 KB
testcase_05 AC 39 ms
52,736 KB
testcase_06 AC 39 ms
52,352 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 39 ms
52,352 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 77 ms
94,592 KB
testcase_15 WA -
testcase_16 AC 145 ms
118,684 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 106 ms
109,176 KB
testcase_20 WA -
testcase_21 AC 99 ms
107,904 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 144 ms
118,740 KB
testcase_25 AC 152 ms
117,264 KB
testcase_26 WA -
testcase_27 AC 73 ms
97,024 KB
testcase_28 AC 191 ms
97,920 KB
testcase_29 AC 75 ms
97,024 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 156 ms
117,100 KB
testcase_33 AC 474 ms
118,560 KB
testcase_34 AC 415 ms
118,368 KB
testcase_35 AC 446 ms
104,596 KB
testcase_36 AC 373 ms
106,956 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 133 ms
109,556 KB
testcase_42 AC 135 ms
109,480 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
    
newA = []
for a in A:
    if a != 0:
        newA.append(a)
    else:
        cnt += 1
def is_ok(d):
    tmp = 0
    for i in range(len(newA)-1):
        if (newA[i+1] - newA[i]) % d == 0:
            tmp += (newA[i+1]-newA[i])//d
        else:
            print(Error)
    if tmp <= cnt:
        return True
    else:
        return False
if newA == []:
    print('Yes')
else:
    g = newA[0]
    for a in newA:
        g = gcd(g,a)
    ds = yaku(g)
    for d in ds:
        if is_ok(d):
            print('Yes')
            exit()
    print('No')
    
    
0