UVA 10491 Cows and Cars (全概率公式)

#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<algorithm>
#include<stack>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif // ONLIN
    int a,b,c;int t1,t2;
    double ans=0;
    while(cin>>a>>b>>c){
        t1=a*b+b*(b-1);
        t2=(a+b)*(a+b-c-1);
        ans=1.0*t1/t2;
        printf("%.5f
",ans);
    }
}
原文地址:https://www.cnblogs.com/linruier/p/9532578.html