题目链接

题意:

  有N个人, M个篮框, 每个人投进球的概率是P。

  问每个人投K次后, 进球数的期望。

思路:

  每个人都是相互独立的, 求出一个人进球数的期望即可。

  进球数和篮框的选择貌似没有什么关系, 所以给的这个M并没有什么卵用。。。。

  每个人进球数的期望为:E = sigma (i * C(K, i) * p ^ i * (1 - p) ^ (k - i));

  总的进球数期望为:N * E

代码:

  

 #include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 20
#define MAXM 100
#define dd cout<<"debug"<<endl
#define p(x) printf("%d\n", x)
#define pd(x) printf("%.7lf\n", x)
#define k(x) printf("Case %d: ", ++x)
#define s(x) scanf("%d", &x)
#define sd(x) scanf("%lf", &x)
#define mes(x, d) memset(x, d, sizeof(x))
#define do(i, x) for(i = 0; i < x; i ++)
int n, m, k;
double p;
double C[MAXN][MAXN];
void init()
{
C[][] = ;
for(int i = ; i < MAXN; i ++)
{
C[i][] = ;
for(int j = ; j <= i; j ++)
C[i][j] = C[i-][j] + C[i-][j-];
}
}
double cal(int x)
{
double p_temp = 1.0;
for(int i = ; i <= x; i ++)
p_temp *= p;
for(int j = ; j <= n - x; j ++)
p_temp *= (1.0 - p);
return x * C[n][x] * p_temp;
} int main()
{
int T;
int kcase = ;
init();
scanf("%d", &T);
while(T --)
{
scanf("%d %d %d %lf", &n, &m, &k, &p);
double ans = ;
for(int i = ; i <= n; i ++)
ans += cal(i);
ans *= k;
k(kcase), pd(ans);
}
return ;
}

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. LightOJ - 1317 Throwing Balls into the Baskets 期望

    题目大意:有N个人,M个篮框.K个回合,每一个回合每一个人能够投一颗球,每一个人的命中率都是同样的P.问K回合后,投中的球的期望数是多少 解题思路:由于每一个人的投篮都是一个独立的事件.互不影响.所以 ...

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

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

  4. KUANGBIN带你飞

    KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题    //201 ...

  5. [kuangbin带你飞]专题1-23题目清单总结

    [kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 Fli ...

  6. ACM--[kuangbin带你飞]--专题1-23

    专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find T ...

  7. LightOJ 1317 第八次比赛 A 题

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

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

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

  9. LightOJ 1317 第六周比赛A题

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

随机推荐

  1. 如何去除CISCO交换机中的口令??

    加电后按住交换机前面的那个按钮 灯不闪了以后松手这时交换机会进入switch:模式输入命令 flash然后 dir flash:你会发现有个 config.text 的文件 你的密码和配置都保存在那里 ...

  2. 使用摘要流获取文件的MD5

    摘要流是过滤流的一种,使用它可以再读取和写入流时获取流的摘要信息(MD5/SHA). 使用摘要流包装流时,需要额外传递一个MessageDigest对象, MessageDigest md=Messa ...

  3. input 的 placeholder属性在IE8下的兼容处理

    placeholder是input标签的新属性,在使用的时候有两个问题: 1.IE8 下不兼容 处理思路: 如果浏览器不识别placeholder属性,给input添加类名placeholder,模仿 ...

  4. PHP中将数据库中的数据显示在网页

    最近没事把以前的东西感觉还可以的又简单的看了以下,因为还在学习新的东西,所以,发表的博客也不是很多,也许是有感而发吧. 这次讲的是mysql数据库中的数据使用php如何显示在网页中.首先,先建好自己的 ...

  5. maven跳过单元测试

    24.跳过单元测试 <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>mav ...

  6. 【转载】NIO客户端序列图

    步骤一:打开SocketChannel,绑定客户端本地地址(可选,默认系统会随机分配一个可用的本地地址),示例代码如下: SocketChannel clientChannel = SocketCha ...

  7. 有关IT的小笑话

    路上看到一个女孩朝我走来:“请问你是不是学计算机的?”我疑惑的点点头,她兴奋的又问:“那你有女朋友吗?”我兴奋的摇头:“没有啊,是不是你家电脑坏了?”她转身对后面的女孩说:“看吧,我就知道这种背双肩包 ...

  8. Jquery Table添加行、删除行

    html页面代码 <table id="tblUserInfo"> </table> Js代码 function DealUserInfo(qty){ ) ...

  9. ACM——完数

    完数 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte 总提交:1930            测试通过:413 描述 自然数中,完数寥若晨 ...

  10. 命令精解之DOS批处理

    前言 最近对于批处理技术的探讨比较热,也有不少好的批处理程序发布,但是如果没有一定的相关知识恐怕不容易看懂和理解这些批处理文件,也就更谈不上自己动手编写了,古语云:“授人以鱼,不如授人以渔.”因为网上 ...