Archer 【CF--312B】

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))).


Input

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.

Sample Input

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>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值