8976: ICPC2017 - Coin II
[Creator : ]
Description
Bob has a not even coin, every time he tosses the coin, the probability that the coin's front face up is $\frac{q}{p}\ (\frac{q}{p} \le \frac{1}{2})$
The question is, when Bob tosses the coin $k$ times, what's the probability that the frequency of the coin facing up is even number.
If the answer is $\frac{X}{Y}$, because the answer could be extremely large, you only need to print $(X * Y^{-1}) \mod (10^9+7)$.
The question is, when Bob tosses the coin $k$ times, what's the probability that the frequency of the coin facing up is even number.
If the answer is $\frac{X}{Y}$, because the answer could be extremely large, you only need to print $(X * Y^{-1}) \mod (10^9+7)$.
Input
First line an integer $T\ (T≤100)$, indicates the number of test cases.
Then Each line has $3$ integer $p,q,k\ (1\le p,q,k \le 10^7)$ indicates the $i$-th test case.
Then Each line has $3$ integer $p,q,k\ (1\le p,q,k \le 10^7)$ indicates the $i$-th test case.
Output
For each test case, print an integer in a single line indicates the answer.
Sample 1 Input
2
2 1 1
3 1 2
Sample 1 Output
500000004
555555560