結果

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

ソースコード

diff #

import math

def compute_gcd(arr):
    current_gcd = abs(arr[0])
    for num in arr[1:]:
        current_gcd = math.gcd(current_gcd, abs(num))
        if current_gcd == 0:
            break
    return current_gcd

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    K = int(input[idx])
    idx += 1
    A = list(map(int, input[idx:idx+N]))
    idx += N
    
    if K in A:
        print("Yes")
        return
    
    gcd = compute_gcd(A)
    if gcd == 0:
        if K == 0:
            print("Yes")
        else:
            print("No")
    else:
        if K % gcd == 0:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()
0