#K46412. Taco: Subset Sum Multiple Problem
Taco: Subset Sum Multiple Problem
Taco: Subset Sum Multiple Problem
You are given several test cases. For each test case, you are provided with a deck of n cards, where each card contains an integer. You are also given an integer m. Your task is to determine if there exists a non-empty subset of these cards such that the sum of the numbers on the subset is a multiple of m. In other words, check if there exists a subset S (where S is not empty) satisfying
$\displaystyle \sum_{i \in S} a_i \equiv 0 \; (\bmod\; m)$
The input will be provided in a specific format from stdin and your output should be written to stdout.
inputFormat
The first line of input contains a single integer t
, indicating the number of test cases.
For each test case, there are two lines:
- The first line contains two integers
n
andm
separated by a space, wheren
is the number of cards andm
is the divisor. - The second line contains
n
integers representing the values on the cards.
outputFormat
For each test case, output a single line containing YES
if such a non-empty subset exists, or NO
otherwise.
3
5 3
1 2 3 4 5
4 5
5 10 15 20
3 11
1 2 3
YES
YES
NO
</p>