Bob has a not even coin, every time he tosses the coin, the probability that the coin’s front face up is qp(qp≤12)pq(pq≤21)pq(pq≤21).
The question is, when Bob tosses the coin kkk times, what’s the probability that the frequency of the coin facing up is even number.
If the answer is YX, because the answer could be extremely large, you only need to print (X∗Y−1)mod(109+7)(X∗Y−1)mod(109+7)(X∗Y−1)mod(109+7).
Input Format
First line an integer T, indicates the number of test cases$ (T≤100T \le 100T≤100).$
Then Each line has 333 integer p,q,k(1≤p,q,k≤107)p,q,k(1\le p,q,k \le 10^7)p,q,k(1≤p,q,k≤107) indicates the i-th test case.
Output Format
For each test case, print an integer in a single line indicates the answer.
题意:
给你一枚不均匀的硬币, 正面朝上的概率是 q / p;现在扔 k 次, 求正面朝上次数为偶数次的概率。