Uva10491 cows and cars
来源:互联网 发布:简述分组转发算法 编辑:程序博客网 时间:2024/06/07 10:54
https://uva.onlinejudge.org/index.php?option=comonlinejudge&Itemid=8&page=showproblem&problem=1432
题目大意:给定a,b,c表示表示有多少个牛,多少个车和一次开几个门。
题目分析:分为两种情况;1.第一次开到的是牛,概率为a/(a+b)。而第二次开到车的概率就是b/(a+b-c-1)。
2.第一次开的的是车,概率为b/(a+b)。而第二次开到车的概率就是(b-1)/(a+b-c-1)。
两个概率相加就是总的概率。
#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream>#include<algorithm>#include<functional>#include<cmath>#include<cctype>#include<cassert>#include<climits>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define ForD(i,n) for(int i=n;i;i--)#define Forp(x) for(int p=pre[x];p;p=next[p])#define RepD(i,n) for(int i=n;i>=0;i--)#define MEM(a) memset(a,0,sizeof(a))#define MEMI(a) memset(a,127,sizeof(a))#define MEMi(a) memset(a,128,sizeof(a))#define INF (2139062143)#define phiF (1000000006)#define MAXN (1000000+10)typedef long long LL;int a,b,c;int main(){for (;~scanf("%d%d%d",&a,&b,&c);){printf("%.5f\n",1.0*(a*b)/((a+b)*(a+b-c-1))+1.0*(b*(b-1))/((a+b)*(a+b-c-1)));}}
0 0
- Uva10491 cows and cars
- uva10491 Cows and Cars
- UVa10491 - Cows and Cars(概率)
- uva10491 - Cows and Cars(牛和车)
- UVA10491 - Cows and Cars(概率)
- 【全概率公式】Cows and Cars, UVa10491
- 10491 - Cows and Cars
- Cows and Cars
- 10491 - Cows and Cars
- Cows and Cars UVA
- Cows and Cars UVA
- UVA 10491-Cows and Cars
- UVA - 10491 Cows and Cars
- UVa 10491 - Cows and Cars
- UVA - 10491 Cows and Cars
- UVa 10491 - Cows and Cars
- UVA 10491 Cows and Cars
- uva 10491 Cows and Cars
- 【HDU】-2602-Bone Collector(01背包)
- iOS中_(下划线)和self.的区别
- hdu1247 hat's words 字典树
- 关于地球生命的猜想
- tuxedo实战
- Uva10491 cows and cars
- 华为OJ——(练习用)挑7
- UNITY之动态创建NGUI对象
- 服务器架构设计
- Flume日志收集分层架构应用实践
- java线程
- 高通平台环境搭建,编译,系统引导流程分析
- Openwrt安装samba服务
- 从item-base到svd再到rbm,多种Collaborative Filtering(协同过滤算法)从原理到实现