#C5799. Special Subsequence Divisibility

    ID: 49487 Type: Default 1000ms 256MiB

Special Subsequence Divisibility

Special Subsequence Divisibility

You are given an array of n integers and an integer m. Your task is to find any non-empty subsequence (not necessarily contiguous) of the array such that the sum of its elements is divisible by m.

In mathematical notation, you need to select a non-empty set of indices \(I \subseteq \{1,2,\ldots,n\}\) such that:

\(\sum_{i \in I} a_i \equiv 0 \pmod{m}\)

If such a subsequence exists, print YES and one valid sequence of 1-indexed positions; otherwise, print NO.

inputFormat

The first line contains two integers (n) and (m) separated by a space. The second line contains (n) integers representing the array elements. (1 \le n \le 20) is suggested for feasibility of the solution. The indices are 1-indexed.

outputFormat

If a valid subsequence is found, output YES on the first line, followed by a second line containing the 1-indexed positions of the chosen elements, separated by spaces. If no such subsequence exists, output only NO.## sample

5 3
1 2 3 4 5
YES

1 2

</p>