题目大意:有N个人,M个篮框。K个回合,每一个回合每一个人能够投一颗球,每一个人的命中率都是同样的P。问K回合后,投中的球的期望数是多少

解题思路:由于每一个人的投篮都是一个独立的事件。互不影响。所以每回合投中的球的期望数是同样的

仅仅需求得一回合的期望再乘上K就答案了

#include<cstdio>
#define maxn 100
double ans, p;
int n, m, k;
int c[20][20]; void init() {
c[1][1] = c[1][0] = 1;
for(int i = 2; i < 20; i++) {
c[i][i] = c[i][0] = 1;
for(int j = 1; j < i; j++)
c[i][j] = c[i-1][j] + c[i-1][j-1];
}
} double count(int j) {
double t = 1.0;
for(int i = 0; i < j; i++)
t *= p; for(int i = 0; i < n - j; i++)
t *= (1.0 - p); return t * j * c[n][j];
} int main() {
int test, cas = 1;
scanf("%d", &test);
init();
while(test--) {
scanf("%d%d%d%lf", &n, &m, &k, &p);
ans = 0.0;
for(int i = 0; i <= n; i++)
ans += count(i); printf("Case %d: %.7lf\n", cas++ ,ans * k);
}
return 0;
}

LightOJ - 1317 Throwing Balls into the Baskets 期望的更多相关文章

  1. lightOJ 1317 Throwing Balls into the Baskets

    lightOJ  1317  Throwing Balls into the Baskets(期望)  解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/ ...

  2. Light OJ 1317 Throwing Balls into the Baskets 概率DP

    n个人 m个篮子 每一轮每一个人能够选m个篮子中一个扔球 扔中的概率都是p 求k轮后全部篮子里面球数量的期望值 依据全期望公式 进行一轮球数量的期望值为dp[1]*1+dp[2]*2+...+dp[ ...

  3. LightOj_1317 Throwing Balls into the Baskets

    题目链接 题意: 有N个人, M个篮框, 每个人投进球的概率是P. 问每个人投K次后, 进球数的期望. 思路: 每个人都是相互独立的, 求出一个人进球数的期望即可. 进球数和篮框的选择貌似没有什么关系 ...

  4. ACM第六周竞赛题目——A LightOJ 1317

    A - A Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status P ...

  5. LightOJ 1317 第八次比赛 A 题

    Description You probably have played the game "Throwing Balls into the Basket". It is a si ...

  6. LightOJ 1317 第六周比赛A题

    A - A Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu   Description Y ...

  7. LightOJ 1317

    Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %lluDescription You probab ...

  8. LightOJ 1038 - Race to 1 Again(期望+DP)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1038 题意是:给你一个N (1 ≤ N ≤ 105) 每次N都随机选一个因子d,然后让 ...

  9. LightOj 1030 - Discovering Gold(dp+数学期望)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1030 题意:在一个1*n 的格子里,每个格子都有相应的金币数,走到相应格子的话,就会得 ...

随机推荐

  1. Xcode导入第三方库

    Xcode导入第三方库,例如TapkuLibrary iOS开源框架Tapku下载地址:https://github.com/devinross/tapkulibrary.git 1.创建你的工程项目 ...

  2. c++_加法变乘法

    加法变乘法 我们都知道:1+2+3+ ... + 49 = 1225现在要求你把其中两个不相邻的加号变成乘号,使得结果为2015 比如:1+2+3+...+10*11+12+...+27*28+29+ ...

  3. docker:安装

    文章来源:http://www.cnblogs.com/hello-tl/p/8901132.html 0.卸载旧版本 # yum remove docker \ docker-client \ do ...

  4. 刁肥宅详解中缀表达式求值问题:C++实现顺序/链栈解决

    1. 表达式的种类 如何将表达式翻译成能够正确求值的指令序列,是语言处理程序要解决的基本问题,作为栈的应用事例,下面介绍表达式的求值过程. 任何一个表达式都是由操作数(亦称运算对象).操作符(亦称运算 ...

  5. python mock模块使用(一)

    什么是mock unittest.mock是一个用于在Python中进行单元测试的库,Mock翻译过来就是模拟的意思,顾名思义这个库的主要功能是模拟一些东西. 它的主要功能是使用mock对象替代掉指定 ...

  6. maven+Hibernate+mysql环境搭建

    项目结构图如下 一,首先是添加依赖pom.xml <?xml version="1.0" encoding="UTF-8"?> <projec ...

  7. ul标签中,li标签的移除、属性值获取

  8. HDU 4436 str2int

    str2int Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on HDU. Original ID: 4 ...

  9. Python 和 Flask实现RESTful services

    使用Flask建立web services超级简单. 当然,也有很多Flask extensions可以帮助建立RESTful services,但是这个例实在太简单了,不需要使用任何扩展. 这个we ...

  10. Android ShapeDrawable之OvalShape、RectShape、PaintDrawable、ArcShape

     Android ShapeDrawable之OvalShape.RectShape.PaintDrawable.ArcShape Android图形图像基础之OvalShape.RectShap ...