当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6339:Problem H. Eat Cards, Have Fun

题目描述
$n$ cards with distinct integers $a_i$ are arranged in a circle, numbered from $1$ to $n$ in clockwise order.
Initially, Kazari holds an empty array $A$ and stands at card $1$.
She will keep performing the following two operations until all cards have been eaten.
* She appends the number on the current card to $A$ and eats the current card, with probability $\frac{p} {q}$.
* Move to the next card that has not been eaten in clockwise order.
It is obvious that $A$ is a $n$-permutation at the end. Define its value as $k$ if it is $k$-th lexicographically smallest among all $n$-permutations. Please help her work out the expected value of $A$.
输入解释
The first line of the input contains an integer $T$ denoting the number of test cases.
Each test case starts with a positive integer $n$ $(n \le 300, \sum{n} \le 1500)$, denoting the number of cards.
The second line contains two integers $p, q$ $(0 < p < q \le 10 ^ 9, \gcd(p, q) = 1)$, representing the probability.
The third line contains $n$ integers, the $i$-th integer represents the number $a_i$ $(1 \le a_i \le n)$ on the $i$-th card.
输出解释
For each test case, print the expected value $E$ modulo $10 ^ 9 + 7$.
Let $E$ be an irreducible fraction $\frac{a} {b}$, define $E \equiv a \hat{b} \pmod p$, where $b \hat{b} \equiv 1 \pmod p$, assuming $p$ is a prime.
输入样例
2
2
1 2
1 2
5
3 11
5 2 3 4 1
输出样例
333333337
841859064
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6339

最后修改于 2020-10-25T23:30:25+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 262144/262144K(Java/Others)