QOJ.ac

QOJ

Limite de temps : 10 s Limite de mémoire : 256 MB Points totaux : 100

#11391. 和相等的集合

Statistiques

考虑由小于或等于 $n$ 的正整数组成的集合。注意集合中的所有元素都是不同的。同时注意元素的顺序无关紧要,即 $\{3, 5, 9\}$ 和 $\{5, 9, 3\}$ 表示同一个集合。

指定集合中元素的个数为 $k$,它们的和为 $s$,满足条件的集合是有限的。当 $n = 9$,$k = 3$ 且 $s = 23$ 时,$\{6, 8, 9\}$ 是唯一满足条件的集合。通常情况下,可能存在多个这样的集合。当 $n = 9$,$k = 3$ 且 $s = 22$ 时,$\{5, 8, 9\}$ 和 $\{6, 7, 9\}$ 都是可能的。

你需要编写一个程序来计算满足给定条件的集合的数量。

输入格式

输入包含多组数据。数据集的数量不超过 $100$。

每个数据集包含三个整数 $n, k$ 和 $s$,在一行中给出,以空格分隔。你可以假设 $1 \le n \le 20$,$1 \le k \le 10$ 且 $1 \le s \le 155$。

输入的结尾由一行包含三个零的数据表示。

输出格式

对于每个数据集,输出应为一行,包含一个整数,表示满足条件的集合的数量。输出中不应出现其他字符。

你可以假设集合的数量不超过 $2^{31} - 1$。

样例

输入 1

9 3 23
9 3 22
10 3 28
16 10 107
20 8 102
20 10 105
20 10 155
3 4 3
4 2 11
0 0 0

输出 1

1
2
0
20
1542
5448
1
0
0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.