按照题目的去推就好了

两种情况

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 = , 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--c+b) + b/(double)(a+b) * (b-)/(double)(a--c+b);
printf("%.5f\n", ans);
} return ;
}

Cows and Cars UVA - 10491 (古典概率)的更多相关文章

  1. UVa 10491 Cows and Cars (概率&广义三门问题 )

    10491 - Cows and Cars Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ...

  2. UVA10491 - Cows and Cars(概率)

    UVA10491 - Cows and Cars(概率) 题目链接 题目大意:给你n个门后面藏着牛.m个门后面藏着车,然后再给你k个提示.在你作出选择后告诉你有多少个门后面是有牛的,如今问你作出决定后 ...

  3. UVa 10491 - Cows and Cars(全概率)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  4. UVa 10491 - Cows and Cars

    題目:有m+n個們,每個門後面有牛或者車:有n仅仅牛,m輛車,你選擇当中1個: 然後打開当中的k你沒有選中的門後是牛的,問你改變選時得到車的概率. 說明:數學題,概率.全概率公式就可以: 說明:第10 ...

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

    #include<bits/stdc++.h> #include<stdio.h> #include<iostream> #include<cmath> ...

  6. 10491 - Cows and Cars

    描述:要么全选择牛,要么选择一辆车和p-1头牛,那么剩下n+m-p道门可以选择,求选择p道门以后要选择到车的概率 #include <cstdio> int main() { //freo ...

  7. uva 10491

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  8. UVa 10491 奶牛和轿车(全概率公式)

    https://vjudge.net/problem/UVA-10491 题意: 假设有a头牛,b辆车,在最终选择前主持人会替你打开c个有牛的门,输出"总是换门"的策略下,赢得车的 ...

  9. UVa10491 Cows and Cars

    #include<iostream> #include<cstdio> #include<algorithm> int main(){ double a,b,c; ...

随机推荐

  1. (转) 前端面试之js相关问题(一)

    原帖地址:http://stephenzhao.github.io/2016/08/19/Front-end-Job-Interview-Questions/ 最近我也是经历过面试别人和去面试的人了, ...

  2. protobuf工程的编译以及使用

    一. 获取Protocol Buffer 1.1 获得源码 Github:ProtocolBuffer源码 Git clone之:git clone https://github.com/google ...

  3. JavaScript正则表达式练习

    校验邮政编码(由六位组成). var reg = /^\d{6}$/; var str = "130400"; var b = str.match(reg); if (b === ...

  4. SpringBoot (1) idea下的环境搭建及demo

    1.Spring Boot简介 wiki上的介绍: Spring Boot是Spring的常规配置解决方案,用于创建可以“运行”的独立的,生产级的基于Spring的应用程序.[22]它预先配置了Spr ...

  5. Java普通编程和Web网络编程准备工作

    一.工具下载 链接:https://pan.baidu.com/s/1geOdq3h 密码:pzl5 二.Java普通编程 解压下载的资料,并按readme.txt安装jdk和Eclipse. 三.J ...

  6. 自己动手做AI:Google AIY开发工具包解析

    2018年国际消费性电子展(CES)上,最明显的一个趋势是Amazon与Google的语音技术进驻战,如AmazonAlexa进驻到Acer笔电内,Google Assist进驻到KIA汽车内,其他如 ...

  7. C语言—栈

    栈的操作:进栈和出栈 #include "stdafx.h" #include "stack.h" #define maxsize 20 typedef int ...

  8. eos开发实践

    一 下载前端代码 git clone https://github.com/baidang201/eos-todo 二 安装nodejs sudo apt-get install python-sof ...

  9. Facebook190亿美元收购WhatsApp

    Facebook收购WhatsApp,前后只花费10天时间.这是Facebook迄今规模最大的一笔收购,可能也是史上最昂贵的一笔针对靠私人风投起家的企业的收购案. 2月9日,马克•扎克伯格(Mark ...

  10. ES6的新特性(20)—— Module 的加载实现

    Module 的加载实现 上一章介绍了模块的语法,本章介绍如何在浏览器和 Node 之中加载 ES6 模块,以及实际开发中经常遇到的一些问题(比如循环加载). 浏览器加载 传统方法 HTML 网页中, ...