結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー gew1fw
提出日時 2025-06-12 15:42:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 54,280 KB
最終ジャッジ日時 2025-06-12 15:42:09
合計ジャッジ時間 4,033 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# Calculate the GCD of all absolute values of the elements
current_gcd = 0
for num in a:
    current_gcd = gcd(current_gcd, abs(num))

# Handle the case where all elements are zero
if current_gcd == 0:
    if k == 0:
        print("Yes")
    else:
        print("No")
else:
    # Check if k is a multiple of the GCD
    if k % current_gcd == 0:
        print("Yes")
    else:
        print("No")
0