#P1036. [NOIP 2002 普及组] 选数

    ID: 36 远端评测题 1500ms 128MiB 尝试: 1 已通过: 1 难度: 3 上传者: 标签>搜索2002NOIp 普及组深度优先搜索,DFS素数判断,质数,筛法

[NOIP 2002 普及组] 选数

Description

Given nn integers x1,x2,,xnx_1, x_2, \cdots, x_n, and one integer kk (k<nk<n). Choose any kk integers from the nn integers and add them up to obtain a set of sums. For example, when n=4n=4, k=3k=3, and the four integers are 3,7,12,193, 7, 12, 19, all combinations and their sums are:

3+7+12=223+7+12=22.

3+7+19=293+7+19=29.

7+12+19=387+12+19=38.

3+12+19=343+12+19=34.

Now, you are required to compute how many of these sums are prime numbers.

For example, in the case above, only one sum is prime: 3+7+19=293+7+19=29.

Input Format

The first line contains two integers n,kn, k separated by a space (1n201 \le n \le 20, k<nk<n).

The second line contains nn integers x1,x2,,xnx_1, x_2, \cdots, x_n (1xi5×1061 \le x_i \le 5\times 10^6).

Output Format

Output a single integer representing the number of ways.

4 3
3 7 12 19

1

Hint

【Source】

NOIP 2002 Junior, Problem 2.

Translated by ChatGPT 5