#T504. 组合+判断素数(递归入门)
组合+判断素数(递归入门)
Description
Given n integers b₁, b₂, ..., bₙ
and an integer k (k < n).
Select any k integers from the n integers and add them together to obtain a series of sums.
For example, when n=4, k=3, and the 4 integers are 3, 7, 12, and 19, all possible combinations and their sums are:
3 + 7 + 12 = 22 3 + 7 + 19 = 29 7 + 12 + 19 = 38 3 + 12 + 19 = 34.
Now, you are required to calculate how many of these sums are prime numbers.
In the example above, there is only one sum that is a prime number: 3 + 7 + 19 = 29.
Input Format
The first line contains two integers:n, k (1 ≤ n ≤ 20, k < n)
The second line contains n integers: x₁, x₂, ..., xₙ (1 ≤ xᵢ ≤ 5,000,000)
Output Format
An integer (the number of valid schemes).
CodesOnline