結果

問題 No.1884 Sequence
ユーザー horitaka1999
提出日時 2022-03-25 21:49:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 118,884 KB
最終ジャッジ日時 2024-10-14 05:44:59
合計ジャッジ時間 7,451 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 19
権限があれば一括ダウンロードができます

ソースコード

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