#abc225h. H - Social Distance 2
H - Social Distance 2
Score : points
问题描述
有 把椅子排成一行,分别称为椅子1、椅子2、……、椅子。 每把椅子只能坐一个人。
将会有 个人坐在其中的 把椅子上。这里我们定义得分如下:
,其中 是人们所坐椅子的索引经过排序后的列表。
已知第 个人()正坐在椅子 上。
剩下的 个人有 种方式就座。求所有这些方式下的得分之和。
由于这个和可能非常大,请计算它对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are chairs arranged in a row, called Chair , Chair , , Chair .
A chair seats only one person.
people will sit on of these chairs. Here, let us define the score as follows:
, where is the sorted list of the indices of the chairs the people sit on.
Person is already sitting on Chair .
There are ways for the other people to take seats. Find the sum of the scores for all of these ways.
Since this sum may be enormous, compute it modulo .
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
5 3 2
1 3
Sample Output 1
7
If Person sits on Chair , the score will be .
If Person sits on Chair , the score will be .
If Person sits on Chair , the score will be .
The answer is .
Sample Input 2
6 6 1
4
Sample Output 2
120
The score for every way of sitting will be .
There are ways of sitting, so the answer is .
Sample Input 3
99 10 3
10 50 90
Sample Output 3
761621047
update @ 2024/3/10 09:54:29