uva 11181
直接枚举计算就行;
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 22
using namespace std; double ans[maxn],p[maxn];
bool vis[maxn];
int n,r;
void dfs(int cur,int cot)
{
if(cur>n)
{
if(cot==r)
{
double tmp=;
for(int i=; i<=n; i++)
{
if(vis[i])
tmp*=p[i];
else tmp*=(-p[i]);
}
ans[]+=tmp;
for(int i=; i<=n; i++)
if(vis[i])
ans[i]+=tmp;
}
return;
}
vis[cur]=;
dfs(cur+,cot);
vis[cur]=;
dfs(cur+,cot+);
vis[cur]=;
} int main()
{
int ca=;
while(scanf("%d%d",&n,&r)&&(n+r))
{
for(int i=; i<=n; i++)
{
ans[i]=;
vis[i]=;
}
for(int i=; i<=n; i++)
scanf("%lf",&p[i]);
dfs(,);
printf("Case %d:\n",ca++);
for(int i=;i<=n;i++)
printf("%lf\n",ans[i]/ans[]);
}
return ;
}
uva 11181的更多相关文章
- 概率论 --- Uva 11181 Probability|Given
Uva 11181 Probability|Given Problem's Link: http://acm.hust.edu.cn/vjudge/problem/viewProblem.acti ...
- uva 11181 - Probability|Given(概率)
题目链接:uva 11181 - Probability|Given 题目大意:有n个人去超市买东西,给出r,每个人买东西的概率是p[i],当有r个人买东西的时候,第i个人恰好买东西的概率. 解题思路 ...
- UVA - 11181 数学
UVA - 11181 题意: n个人去买东西,其中第i个人买东西的概率是p[i],最后只有r个人买了东西,求每个人实际买了东西的概率 代码: //在r个人买东西的概率下每个人买了东西的概率,这是条件 ...
- UVa 11181 - Probability|Given(条件概率)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVa 11181 条件概率
题意:n个人选r个人,每个人被选中的概率为pi,问最后每个人被选中的概率是多少. sol:就是个简单的概率题,范围还特别小,深搜秒出...然而公式什么的很多还是需要注意的... 条件概率的公式 ...
- UVA 11181 dfs 概率
N friends go to the local super market together. The probability of their buying something from them ...
- UVa 11181 (条件概率) Probability|Given
题意: 有n个人买东西,第i个人买东西的概率为Pi.已知最终有r个人买了东西,求每个人买东西的概率. 分析: 设事件E为r个人买了东西,事件Ei为第i个人买了东西.所求为P(Ei|E) = P(EiE ...
- uva 11181 - Probability|Given
条件概率公式:P( A|B ) = P( AB ) / P( B ) 表示在事件B发生的前提,事件A发生的可能性: 问题的: 复位事件E:r个人买东西: 事件Ei:文章i个人买东西: 的要求是P( E ...
- Probability|Given UVA - 11181(条件概率)
题目大意:n个人去购物,要求只有r个人买东西.给你n个人每个人买东西的概率,然后要你求出这n个人中有r个人购物并且其中一个人是ni的概率pi. 类似于5个人中 抽出三个人 其中甲是这三个人中的一个的 ...
随机推荐
- Java 字符流实现文件读写操作(FileReader-FileWriter)
Java 字符流实现文件读写操作(FileReader-FileWriter) 备注:字符流效率高,但是没有字节流底层 字节流地址:http://pengyan5945.iteye.com/blog/ ...
- 【OSG细节实现】节点围绕位于axisPos平行于axis的轴进行旋转
//绕着与axis平行的任意轴旋转 void rotate(const std::string& name, float angle, osg::Vec3 axisPos, osg::Vec3 ...
- 大仙说道之Android studio实现Service AIDL
今天要开发过程中要用到AIDL的调用,之前用的eclipse有大量教程,用起来很方便,现在刚换了Android studio,不可否认studio真的很强大,只是很多功能还需要摸索. AIDL(And ...
- IntellijIDEA 使用技巧
1:显示工具栏目 toolbar:view ->ToolBar 2:加载源码 new project ->选择java project ->选择源码所在目录 ->ok
- javascript 数字字符串转为数字
var a="111"; comsole.log(a); //打印出来是个字符串类型 comsole.log(+a); //打印出来是个数字类型 comsole.log ...
- webstorm 自定义代码模板
Ctrl+Shift+A查找设置live 添加代码片段Live Template 编写代码的时候 缩写+Tab 即可输出代码片段 缩写启动对应代码片段的钥匙. 描述代码片段的名字. 模板文本代码片段的 ...
- Nginx 之并发优化
客户端/服务端 连接数 ulimit -n 100000 nginx 链接数 10240 个 worker_connections 10240;允许打开文件数worker_processes 1;wo ...
- 封装鼠标滚轮事件_mousewheel
function mousewheel(obj,fn){ obj.onmousewheel===null ? obj.onmousewheel=fun : obj.addEventListener(' ...
- [大牛翻译系列]Hadoop(12)MapReduce 性能调优:诊断硬件性能瓶颈
6.2.5 硬件性能问题 尽管单独的硬件的MTTF(平均失效前时间)都数以年记,然而在集群中就完全不是这么一回事了.整个集群的MTTF就要小得多.这一节要介绍如何确定CPU,内存,磁盘和网络是否过度利 ...
- 左右滑动删除ListView条目Item--第三方开源--SwipeToDismiss
Android的SwipeToDismiss是github上一个第三方开源框架(github上的项目链接地址:https://github.com/romannurik/Android-SwipeTo ...