Archer 【CF--312B】
来源:互联网 发布:知行理工密码 编辑:程序博客网 时间:2024/06/11 17:10
Description
SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is for SmallR while for Zanoes. The one who shoots in the target first should be the winner.
Output the probability that SmallR will win the match.
题意:SmallR和Zanoes都是射箭运动员。SmallR准备与Zanoes举行一场射箭比赛,SmallR第一个发剪,然后两人轮流进行射箭,SmallR投中靶子的概率为a/b,Zanoes投中靶子的概率为c/d,谁第一个投中靶子谁就获胜,求SmallR赢得比赛的概率。
思路:由概率知识知,p=a/b+a/b*(1-a/b)*(1-c/d)+a/b*((1-a/b)^2)*((1-c/d)^2)+....+a/b*((1-a/b)^n)*((1-c/d)^n),当n很大时,p=a/b*(1/(1-(1-a/b)*(1-c/d))).
A single line contains four integers.
Output
Print a single real number, the probability that SmallR will win the match.
The answer will be considered correct if the absolute or relative error doesn't exceed10 - 6.
1 2 1 2
Sample Output
0.666666666667
<span style="font-family:KaiTi_GB2312;font-size:18px;">#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(){int a,b,c,d;while(~scanf("%d %d %d %d",&a,&b,&c,&d)){double s=(a*1.0/b);double ss=(1-(a*1.0/b))*(1-(c*1.0/d));printf("%.12f\n",s*1.0/(1-ss));}return 0;}</span>
- Archer 【CF--312B】
- CF 312B(Archer-等比数列极限求和)
- CodeForces 312B--Archer
- CodeForces 312B Archer
- codeforces-312B Archer
- B. Archer
- CF 78D Archer's Shot题解
- Archer
- 发布 Archer B-Ware 0.3.0 Standard
- cf-B
- cf B
- CF 1B Spreadsheet
- CF 3B Lorry
- CF 176B
- CF 91B
- cf 131 DIV2 B
- CF 113B || CF196D
- CF 126B
- ramoops&pstore简要说明
- 使用large 限定符 最小宽度限定符
- 初识设计模式
- 斐波那契数列的快速解法
- SharedPreference.Editor的apply和commit方法异同
- Archer 【CF--312B】
- 通过在BasicController使用ModelAttribute标签注入Request/Response/Session
- Struts2框架学习(二) Action
- 插入排序
- 有焦点的TextView
- 学习模式
- UVA 题目624 CD(01背包输出路径啊)
- 深度学习:对实际问题解决者的简要指导
- Android中View 绘制机制