結果

問題 No.1538 引きこもりさんは引き算が得意。
コンテスト
ユーザー gew1fw
提出日時 2025-06-12 15:39:19
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 569 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 230 ms
コンパイル使用メモリ 95,720 KB
実行使用メモリ 78,976 KB
最終ジャッジ日時 2026-07-11 14:55:45
合計ジャッジ時間 6,175 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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