← Home
write a go solution for Description:
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.

Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:

- Two numbers i and j are chosen equiprobable such that (1<=i<j<=n).
- The numbers in the i and j positions are swapped.

Sonya's task is to find the probability that after all the operations are completed, the a array will be sorted in non-decreasing order. She turned to you for help. Help Sonya solve this problem.

It can be shown that the desired probability is either 0 or it can be represented as dfracPQ, where P and Q are coprime integers and Qnotequiv0~pmod10^9+7.

Input Format:
The first line contains two integers n and k (2<=n<=100,1<=k<=10^9) — the length of the array a and the number of operations.

The second line contains n integers a_1,a_2,ldots,a_n (0<=a_i<=1) — the description of the array a.

Output Format:
If the desired probability is 0, print 0, otherwise print the value P*Q^-1 pmod10^9+7, where P and Q are defined above.

Note:
In the first example, all possible variants of the final array a, after applying exactly two operations: (0,1,0), (0,0,1), (1,0,0), (1,0,0), (0,1,0), (0,0,1), (0,0,1), (1,0,0), (0,1,0). Therefore, the answer is dfrac39=dfrac13.

In the second example, the array will not be sorted in non-decreasing order after one operation, therefore the answer is 0.. Output only the code with no comments, explanation, or additional text.