#K72637. Subset Sum Divisible by K

    ID: 33798 Type: Default 1000ms 256MiB

Subset Sum Divisible by K

Subset Sum Divisible by K

Given an array of n non-negative integers and an integer k, determine if there exists a non-empty subset whose sum is divisible by k. In other words, find a subset S ⊆ {a1, a2, ..., an} such that:

\(\sum_{x\in S}x\equiv0 \pmod{k}\)

If such a subset exists, output YES and one valid subset. Otherwise, output NO.

inputFormat

The first line contains two integers n and k where n is the number of elements in the array and k is the divisor.

The second line contains n non-negative integers separated by spaces.

outputFormat

If a valid subset exists, output YES on the first line, followed by the elements of one valid subset (separated by spaces) on the second line.

If no such subset exists, output NO.

## sample
5 3
1 2 3 4 5
YES

1 2 3

</p>