zoukankan      html  css  js  c++  java
  • Cows and Cars UVA

    按照题目的去推就好了

    两种情况

    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
    ", ans);
        }
    
        return 0;
    }
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    iOS 适配iPhoneX上tableHeaderView发生了高度拉伸、UI出现的空白间距
    无线加密WEP、WPA、WPA2及TKIP、AES
    字符替换操作
    jQuery版本升级问题汇总
    ipv6服务器及环境搭建
    git删除某次提交操作
    五种IO模型
    jQuery1.6以上attr改用prop
    线程创建pthread_create用法(转)
    网络字节序与主机字节序
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9353560.html
Copyright © 2011-2022 走看看