Another Expected Value Problem
시간 제한1초메모리 제한2048 MB
무작위로 원소를 골라 나머지를 한 칸씩 끌어당기는 연산을 k번 수행한 뒤 무작위 원소의 기댓값을 1e9+7로 나눈 나머지로 구한다.
문제
You are given an array of integers. You then perform the following process times.
-
Choose an integer where , uniformly at random.
-
For each , move one unit closer to . Formally, for each ,
- If , increment by
- If , decrement by
- If , do not modify the value of .
After performing this process times, you select an integer where uniformly at random. What is the expected value of ?
It can be shown that this value can be represented as where and are coprime integers and . Print the value of modulo .
입력
The first line of the input contains a single integer () --- the number of test cases.
The first line of each test case contains two integers and () --- the length of the array and the number of operations you will perform.
The second line of each test case will contain integers () --- the initial array .
It is guaranteed that the sum of over all test cases, and the sum of over all test cases, do not exceed .
출력
For each test case, output a single line containing the expected value of at the end of this process, modulo as described above.
힌트
In the first sample case, since all elements of are initially equal, none of them will change after any of the operations. Therefore, the final array will be , so the expected value of a random element of the final array is .
In the second sample case, there is a chance of choosing in the operation, and a chance of choosing .
- If is chosen, all elements of the array will move closer to , so will go from to . The expected value of a random element of this array is .
- If is chosen, all elements of the array will move closer to , so will go from to . The expected value of a random element of this array is .
So there is a chance of the expected value being , and a chance of it being . Therefore, the final expected value is , which is equivalent to modulo .