import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    static int N;
    static int K;
    static int[] arr;
    static boolean remainder; 
    
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        
        N = Integer.parseInt(st.nextToken());
        K = Integer.parseInt(st.nextToken());
        arr = new int[N]; 
        for (int i=0; i<N; i++) {
            arr[i] = Integer.parseInt(br.readLine());
        }

        boolean[] remainder = new boolean[1000];
        remainder[0] = true; 
        for (int i=0; i<N; i++) {
            boolean[] this_remainder = remainder.clone();
            int num = arr[i];
            
            for (int j = 0; j < 1000; j++) {
               if(remainder[j]) {
                   int this_num = num + j;
                   this_remainder[this_num % 1000] = true;
               } 
            }

            remainder = this_remainder;
            
        }
        
        
        // for (int i=0; i<=K; i++) {
        //     System.out.println(i + " " + remainder[i]);
        // }
        
        
        System.out.println(remainder[K] ? "Yes" : "No") ;
        
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: