WTSRUVF

按照题目的去推就好了

两种情况

1、第一次选择奶牛的门  概率是 a/(a+b) 打开c扇门后  除去选择的门 还剩 a-1-c+b扇门  则选到车的概率为b/(a-1-c+b)

2、第一次选择车的门 概率是b/(a+b) 打开c扇门后  除去选择的门 还剩 a-c+b-1扇门  则再次选择选到车的概率为(b-1)/(a-c+b-1)

最后结果即为 a/(a+b)* b/(a-1-c+b) + b/(a+b)* (b-1)/(a-c+b-1)

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define rap(a, n) for(int i=a; i<=n; i++)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _  ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = 10010, INF = 0x7fffffff;

int main()
{
    int a, b, c;
    while(~scanf("%d%d%d", &a, &b, &c))
    {
        double ans = a/(double)(a+b) * b/(double)(a-1-c+b) + b/(double)(a+b) * (b-1)/(double)(a-1-c+b);
        printf("%.5f\n", ans);
    }

    return 0;
}

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-06-14
  • 2021-04-14
  • 2021-11-17
  • 2022-01-23
  • 2021-11-17
  • 2021-11-17
猜你喜欢
  • 2021-12-18
  • 2021-07-27
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
  • 2021-12-26
相关资源
相似解决方案