#abc267g. G - Increasing K Times
G - Increasing K Times
Score : points
问题描述
给定一个长度为 的整数序列 。
求满足以下条件的置换 的个数,模 :
- 存在恰好 个整数 ,满足 (包含两端点),且有 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given an integer sequence of length .
Find the number, modulo , of permutations of such that:
- there exist exactly integers between and (inclusive) such that .
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
4 2
1 1 2 2
Sample Output 1
4
Four permutations satisfy the condition: $P = (1, 3, 2, 4), (1, 4, 2, 3), (2, 3, 1, 4), (2, 4, 1, 3)$.
Sample Input 2
10 3
3 1 4 1 5 9 2 6 5 3
Sample Output 2
697112
update @ 2024/3/10 11:17:17