結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー gew1fw
提出日時 2025-06-12 20:38:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 569 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 81,580 KB
実行使用メモリ 54,400 KB
最終ジャッジ日時 2025-06-12 20:38:19
合計ジャッジ時間 3,606 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

# Check if K is already present in the array
if k in a:
    print("Yes")
    exit()

# Check if all elements are the same
all_same = True
for num in a[1:]:
    if num != a[0]:
        all_same = False
        break
if all_same:
    print("Yes" if k == 0 else "No")
    exit()

# Calculate the GCD of differences
g = 0
for num in a[1:]:
    d = abs(num - a[0])
    g = math.gcd(g, d)

# Check if K is a multiple of the GCD
if g != 0 and k % g == 0:
    print("Yes")
else:
    print("No")
0