atcoder#ARC060A. [ABC044C] 高橋君とカード

[ABC044C] 高橋君とカード

Score : 300300 points

Problem Statement

Tak has NN cards. On the ii-th (1iN)(1 \leq i \leq N) card is written an integer xix_i. He is selecting one or more cards from these NN cards, so that the average of the integers written on the selected cards is exactly AA. In how many ways can he make his selection?

Constraints

  • 1N501 \leq N \leq 50
  • 1A501 \leq A \leq 50
  • 1xi501 \leq x_i \leq 50
  • N,A,xiN,\,A,\,x_i are integers.

Partial Score

  • 200200 points will be awarded for passing the test set satisfying 1N161 \leq N \leq 16.

Input

The input is given from Standard Input in the following format:

NN AA

x1x_1 x2x_2 ...... xNx_N

Output

Print the number of ways to select cards such that the average of the written integers is exactly AA.

4 8
7 9 8 9
5
  • The following are the 55 ways to select cards such that the average is 88:- Select the 33-rd card.
    • Select the 11-st and 22-nd cards.
    • Select the 11-st and 44-th cards.
    • Select the 11-st, 22-nd and 33-rd cards.
    • Select the 11-st, 33-rd and 44-th cards.
3 8
6 6 9
0
8 5
3 6 2 8 7 6 5 9
19
33 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
8589934591
  • The answer may not fit into a 3232-bit integer.