测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A10494. Student's Camp

编程题 普及/提高-

题目描述

Alex studied well and won the trip to student camp Alushta, located on the seashore.

Unfortunately, it's the period of the strong winds now and there is a chance the camp will be destroyed! Camp building can be represented as the rectangle of $n+2$ concrete blocks height and $m$ blocks width.

Every day there is a breeze blowing from the sea. Each block, except for the blocks of the upper and lower levers, such that there is no block to the left of it is destroyed with the probability ![](/uploads/acgo/image/96007a7a5660d480_dc00000f065d.jpeg). Similarly, each night the breeze blows in the direction to the sea. Thus, each block (again, except for the blocks of the upper and lower levers) such that there is no block to the right of it is destroyed with the same probability $p$ . Note, that blocks of the upper and lower level are indestructible, so there are only $n·m$ blocks that can be destroyed.

The period of the strong winds will last for $k$ days and $k$ nights. If during this period the building will split in at least two connected components, it will collapse and Alex will have to find another place to spend summer.

Find the probability that Alex won't have to look for other opportunities and will be able to spend the summer in this camp.

输入格式

The first line of the input contains two integers $n$ and $m$ ( $1<=n,m<=1500$ ) that define the size of the destructible part of building.

The second line of the input contains two integers $a$ and $b$ ( $1<=a<=b<=10^{9}$ ) that define the probability $p$ . It's guaranteed that integers $a$ and $b$ are coprime.

The third line contains a single integer $k$ ( $0<=k<=100000$ ) — the number of days and nights strong wind will blow for.

输出格式

Consider the answer as an irreducible fraction is equal to ![](/uploads/luogu/CF708E/80a3a0e00c79b470772b3be90efd3e0d2e457bd7_cae6fc495fc6.png). Print one integer equal to ![](/uploads/luogu/CF708E/554b30b982e35fb63eb76dd412a37e11659c08f3_cedae9484dd4.png). It's guaranteed that within the given constraints ![](/uploads/acgo/image/018ae5ad57c92812_3e32b7e4b92e.jpeg).

输入输出样例

输入 #1
2 2
1 2
1
输出 #1
937500007
输入 #2
5 1
3 10
1
输出 #2
95964640
输入 #3
3 3
1 10
5
输出 #3
927188454

说明/提示

In the first sample, each of the four blocks is destroyed with the probability ![](/uploads/luogu/CF708E/fda96725ccc697b767e5edbf0d5cfb5ba17d9aa2_492f8312457e.png). There are $7$ scenarios that result in building not collapsing, and the probability we are looking for is equal to ![](/uploads/luogu/CF708E/dda8ba13f4feb6c7325a04d07cb771a7084c4ba2_e6f9223a35f6.png), so you should print ![](/uploads/acgo/image/e873feec87912fe7_5d4445f5cdfe.jpeg)

![](/uploads/acgo/image/f449d010daed3c37_9003be82786b.jpeg)
上一题 去做题 下一题