CF891E.Lust
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A false witness that speaketh lies!
You are given a sequence containing n integers. There is a variable res that is equal to 0 initially. The following process repeats k times.
Choose an index from 1 to n uniformly at random. Name it x. Add to res the multiply of all a__i's such that 1 ≤ i ≤ n, but i ≠ x. Then, subtract a__x by 1.
You have to find expected value of res at the end of the process. It can be proved that the expected value of res can be represented as an irreducible fraction
. You have to find
.
一个说谎的假见证者!
给你一个包含 n 个整数的序列。初始时有一个变量 res,其值为 0。以下过程重复执行 k 次:
- 在 1 到 n 中等概率随机选择一个下标,记为 x;
- 将所有满足 1≤i≤n 且 i=x 的 ai 的乘积加到 res 上;
- 将 ax 减 1。
你需要求出该过程结束时 res 的期望值。可以证明:res 的期望值可表示为一个既约分数 qp,其中 p 和 q 互质。你需要输出 p⋅q−1mod109+7。
输入格式
The first line contains two integers n and k (1 ≤ n ≤ 5000, 1 ≤ k ≤ 109) — the number of elements and parameter k that is specified in the statement.
The second line contains n space separated integers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 109).
第一行包含两个整数 n 和 k(1≤n≤5000,1≤k≤109)—— 分别表示元素个数以及题目描述中指定的参数 k。
第二行包含 n 个用空格分隔的整数 a1,a2,...,an(0≤ai≤109)。
输出格式
Output a single integer — the value
.
输出一个整数——该值为
。
输入输出样例
输入#1
2 1 5 5
输出#1
5
输入#2
1 10 80
输出#2
10
输入#3
2 2 0 0
输出#3
500000003
输入#4
9 4 0 11 12 9 20 7 8 18 2
输出#4
169316356
输入解题思路,AI测评打分。不知道怎么写?