CF1151F.Sonya and Informatics

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 aa of length nn , consisting only of the numbers 00 and 11 , and the number kk . Exactly kk times the following happens:

  • Two numbers ii and jj are chosen equiprobable such that ( 1i<jn1 \leq i < j \leq n ).
  • The numbers in the ii and jj positions are swapped.

Sonya's task is to find the probability that after all the operations are completed, the aa 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 00 or it can be represented as PQ\dfrac{P}{Q} , where PP and QQ are coprime integers and Q≢0 (mod109+7)Q \not\equiv 0~\pmod {10^9+7} .

输入格式

The first line contains two integers nn and kk ( 2n100,1k1092 \leq n \leq 100, 1 \leq k \leq 10^9 ) — the length of the array aa and the number of operations.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 0ai10 \le a_i \le 1 ) — the description of the array aa .

输出格式

If the desired probability is 00 , print 00 , otherwise print the value PQ1P \cdot Q^{-1} (mod109+7)\pmod {10^9+7} , where PP and QQ are defined above.

输入输出样例

  • 输入#1

    3 2
    0 1 0
    

    输出#1

    333333336
  • 输入#2

    5 1
    1 1 1 0 0
    

    输出#2

    0
  • 输入#3

    6 4
    1 0 0 1 1 0
    

    输出#3

    968493834

说明/提示

In the first example, all possible variants of the final array aa , after applying exactly two operations: (0,1,0)(0, 1, 0) , (0,0,1)(0, 0, 1) , (1,0,0)(1, 0, 0) , (1,0,0)(1, 0, 0) , (0,1,0)(0, 1, 0) , (0,0,1)(0, 0, 1) , (0,0,1)(0, 0, 1) , (1,0,0)(1, 0, 0) , (0,1,0)(0, 1, 0) . Therefore, the answer is 39=13\dfrac{3}{9}=\dfrac{1}{3} .

In the second example, the array will not be sorted in non-decreasing order after one operation, therefore the answer is 00 .

首页