G. [NOIP 2002 普及组] 选数

    远端评测题 1500ms 128MiB

[NOIP 2002 普及组] 选数

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem 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

第 22 课:枚举算法-子集枚举

未认领
状态
已结束
题目
11
开始时间
2026-7-2 17:00
截止时间
2026-7-17 17:00
可延期
24 小时