CSES - Meet in the Middle
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
512M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
You are given an array of ~n~ numbers. In how many ways can you choose a subset of the numbers with sum ~x~?
Input
- The first input line has two numbers ~n~ and ~x~: the array size and the required sum.
The second line has ~n~ integers ~t\_1,t\_2,\dots,t\_n~: the numbers in the array.
Output
- Print the number of ways you can create the sum ~x~.
Constraints
- ~1 \le n \le 40~
- ~1 \le x \le 10^9~
- ~1 \le t\_i \le 10^9~
Example Input
4 5
1 2 3 2
Example Output
3
Bình luận