2017 ACM-ICPC 亚洲区(西安赛区)网络赛: B. Coin 【概率题】【数论】
Bob has a not even coin(就是一个不均匀的硬币,朝上的概率不一定是1/2), every time he tosses the coin, the probability that the coin's front face up is q/p(q/p<=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(就是硬币朝上次数为偶数次的概率和,0次也算).
If the answer is X/Y, because the answer could be extremely large, you only need to print (X * Y^{-1}) /mod (10^9+7).
Input Format
First line an integer TT, indicates the number of test cases (T≤100).
Then Each line has 33 integer p,q,k(1<= p,q,k ,k<=10^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
思路:
题目说的有点晦涩。
一个组合数学题。。。。。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MOD=1e9+;
typedef long long ll;
ll p,q,k; ll qmod(ll x,ll n)
{
ll res=;
while(n){
if(n&) res=(res*x)%MOD;
x=(x*x)%MOD;
n/=;
}
return res;
} int main()
{
int T;
cin>>T;
while(T--)
{
cin>>p>>q>>k;
ll x=qmod(p,k);
ll y=qmod(p-*q,k);
ll ans=((x+y)%MOD*qmod(*x,MOD-))%MOD;
cout<<ans<<endl;
}
return ;
}
2017 ACM-ICPC 亚洲区(西安赛区)网络赛: B. Coin 【概率题】【数论】的更多相关文章
- HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛)
HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛) Panda Time Limit: 10000/4000 MS (Java/Others) Memory Limit: ...
- 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)
摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem【状态压缩】
2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem 题意:给定N和α还有M个U={1,2,3,...N}的子集,求子集X个数,X满足:X是U ...
- ICPC 2018 徐州赛区网络赛
ACM-ICPC 2018 徐州赛区网络赛 去年博客记录过这场比赛经历:该死的水题 一年过去了,不被水题卡了,但难题也没多做几道.水平微微有点长进. D. Easy Math 题意: ...
- Skiing 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛H题(拓扑序求有向图最长路)
参考博客(感谢博主):http://blog.csdn.net/yo_bc/article/details/77917288 题意: 给定一个有向无环图,求该图的最长路. 思路: 由于是有向无环图,所 ...
- [刷题]ACM/ICPC 2016北京赛站网络赛 第1题 第3题
第一次玩ACM...有点小紧张小兴奋.这题目好难啊,只是网赛就这么难...只把最简单的两题做出来了. 题目1: 代码: //#define _ACM_ #include<iostream> ...
- 2017 ACM/ICPC(西安)赛后总结
早上8:00的高铁,所以不得不6点前起床,向火车站赶……到达西安后已经是中午,西工大距离西安北站大概3小时车程的距离,只好先解决午饭再赶路了……下午3.30的热身赛,一行人在3.35左右赶到了赛场,坐 ...
- 2016 ACM/ICPC亚洲区大连站-重现赛 解题报告
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5979 按AC顺序: I - Convex Time limit 1000 ms Memory li ...
- 2014ACM/ICPC亚洲区鞍山赛区现场赛1009Osu!
鞍山的签到题,求两点之间的距离除以时间的最大值.直接暴力过的. A - Osu! Time Limit:1000MS Memory Limit:262144KB 64bit IO Fo ...
- [刷题]ACM ICPC 2016北京赛站网络赛 D - Pick Your Players
Description You are the manager of a small soccer team. After seeing the shameless behavior of your ...
随机推荐
- 循环读取文件夹中的图片matlab代码
参考:http://blog.csdn.net/guoxiaojie_415/article/details/21317323:http://blog.csdn.net/qikaihuting/art ...
- bzoj 4373 算术天才⑨与等差数列——线段树+set
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4373 能形成公差为k的等差数列的条件:mx-mn=k*(r-l) && 差分 ...
- TZ_16ES6学习总结
1.块级作用域的引入 在ES6之前,js只有全局作用域和函数作用域,ES6中let关键字为其引入了块级作用域. { var a = 5; let b = 6; } console.log(a); // ...
- SSM3-SVN的安装和搭建环境
1.安装svn 2.创建仓库 3.设置用户 . 4.eclipse和svn的集成 eclipse里安装SVN插件,一般来说,有两种方式: 直接下载SVN插件,将其解压到eclipse的对应目录里 使用 ...
- windows 2008 安装 apache + mysql + php
下载准备 php : http://windows.php.net/downloads/releases/archives/ apache : https://www.apachehaus.com/c ...
- 20190921-雅礼Day1
#error 此人太蒻无法编译 #include<iostream> main(){} Before 哦…… -O2 T1 序列问题:分块(莫队),树状数组,线段树,分治 离线 or 在线 ...
- spring cloud深入学习(二)-----服务注册中心spring cloud eureka
服务治理 主要用来实现各个微服务实例的自动化注册与发现,为啥需要这玩意呢?在一开始比如A系统调用B服务,可能通过手工维护B服务的实例,并且还得采用负载均衡等方式,这些全部都得需要手工维护,等后面系统越 ...
- neo4j批量导入neo4j-import
neo4j数据批量导入 1 neo4j基本参数 1.1 启动与关闭: 1.2 neo4j-admin的参数:控制内存 1.2.1 memrec 是查看参考内存设置 1.2.2 指定缓存–pagecac ...
- Apache HttpComponents 工具类 [ HttpUtil ]
pom.xml <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId&g ...
- JSP-request(httpServletRequest)
HttpServletRequest 1 HttpServletRequest概述 2 request运行流程 3 通过抓包工具抓的http请求 4 请求行信息的相关方法 //1.获得请求方式 Str ...