日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

2017 ACM-ICPC西安网赛B-Coin

發(fā)布時(shí)間:2023/12/13 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2017 ACM-ICPC西安网赛B-Coin 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

B-Coin

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})?p??q??(?p??q???2??1??).

The question is, when Bob tosses the coin?kktimes, what's the probability that the frequency of the coin facing up is even number.

If the answer is?\frac{X}{Y}?Y??X??, because the answer could be extremely large, you only need to print?(X * Y^{-1}) \mod (10^9+7)(X?Y??1??)mod(10?9??+7).

Input Format

First line an integer?TT, indicates the number of test cases (T \le 100T100).

Then Each line has?33?integer?p,q,k(1\le p,q,k \le 10^7)p,q,k(1p,q,k10?7??)?indicates the i-th test case.

Output Format

For each test case, print an integer in a single line indicates the answer.

樣例輸入

2 2 1 1 3 1 2

樣例輸出

500000004 555555560

題目來(lái)源

2017 ACM-ICPC 亞洲區(qū)(西安賽區(qū))網(wǎng)絡(luò)賽

1 //2017-10-24 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 #define ll long long 7 8 using namespace std; 9 10 const int MOD = 1000000007; 11 12 ll quickPow(ll a, ll n){ 13 ll ans = 1; 14 while(n){ 15 if(n&1) 16 ans = (a*ans)%MOD; 17 a = (a*a)%MOD; 18 n >>= 1; 19 } 20 return ans; 21 } 22 23 int main() 24 { 25 ll p, q, k, T; 26 cin>>T; 27 while(T--){ 28 cin>>p>>q>>k; 29 ll X = quickPow(p-2*q, k); 30 ll Y = quickPow(p, k); 31 cout<<(((1+X*quickPow(Y, MOD-2))%MOD) * quickPow(2, MOD-2))%MOD<<endl; 32 } 33 34 return 0; 35 }

?

轉(zhuǎn)載于:https://www.cnblogs.com/Penn000/p/7723449.html

總結(jié)

以上是生活随笔為你收集整理的2017 ACM-ICPC西安网赛B-Coin的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。