B. Archer

来源:互联网 发布:五子棋游戏c语言代码 编辑:程序博客网 时间:2024/04/29 06:02

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

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 exceed 10 - 6.

Sample test(s)
input
1 2 1 2
output
0.666666666667

解题说明:此题是一道概率题,只需要每一轮射击以后前一个人的概率大于第二个人即可


#include <iostream>#include<algorithm>#include<cstdio>#include<cmath>#include<cstring>#include<cstdlib>using namespace std;int main(){int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);printf("%.10f",(float)(a*d)/(a*d+b*c-a*c));return 0;}