結果
| 問題 | 
                            No.1538 引きこもりさんは引き算が得意。
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 15:34:19 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 832 bytes | 
| コンパイル時間 | 189 ms | 
| コンパイル使用メモリ | 82,540 KB | 
| 実行使用メモリ | 732,468 KB | 
| 最終ジャッジ日時 | 2025-06-12 15:35:37 | 
| 合計ジャッジ時間 | 8,957 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 MLE * 1 | 
| other | AC * 35 WA * 9 MLE * 1 -- * 9 | 
ソースコード
import sys
import math
def main():
    N, K = map(int, sys.stdin.readline().split())
    A = list(map(int, sys.stdin.readline().split()))
    
    if K in A:
        print("Yes")
        return
    
    # Compute GCD
    current_gcd = A[0]
    for num in A[1:]:
        current_gcd = math.gcd(current_gcd, abs(num))
    if current_gcd == 0:
        current_gcd = abs(A[0])
    
    if K % current_gcd != 0:
        print("No")
        return
    
    # Now, check if K can be expressed as a sum of subset with +/- signs
    target = K
    possible = {0}
    for num in A:
        temp = set()
        for p in possible:
            temp.add(p + num)
            temp.add(p - num)
        possible.update(temp)
    
    if target in possible:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()
            
            
            
        
            
gew1fw