7035.Subsets with Fixed Average

Time Limit: 1s Memory Limit: 512MB

You are given an array of $n$ integers. Your task is to count the number of non-empty subsets of the given array with average equal to $a$ .

Input Format(From the terminal/stdin)

The first line has two integers $n$ and $a$ : the size of the array and the target average.

The next line has $n$ integers $x_1, x_2,\dots, x_n$ : the contents of the array.

  • $1 \le n \le 500$
  • $1 \le a \le 500$
  • $1 \le x_i \le 500$

Output Format(To the terminal/stdout)

Print one integer: the number of non-empty subsets with average equal to $a$ , modulo $10^9 + 7$ .

Sample Input

Copy
5 2
1 1 2 3 4
 · \n
 · · · · \n

Sample Output

Copy
7
 \n
Source: CSES, Additional Problems I, 3302

Submit

请先 登录

© 2025 FAQs