#abc199e. E - Permutation
E - Permutation
Score : points
问题陈述
打印满足以下条件的序列 的数量,其中 是 的排列:
- 对于每个整数 (满足 ),在 中至多有 个数小于等于 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Print the number of sequences that are permutations of and satisfy the following condition:
- for every integer such that , at most numbers among are less than or equal to .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 1
2 2 1
Sample Output 1
4
The four sequences satisfying the condition are:
and violate the condition, since each of them has two numbers less than or equal to among .
Sample Input 2
5 2
3 3 2
4 4 3
Sample Output 2
90
Sample Input 3
18 0
Sample Output 3
6402373705728000
相关
在下列比赛中: