题目链接

题意:

  有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. JS问题Uncaught ReferenceError:XXXX is not defined

    背景: html中一个table,table中进行分页.每行后面有一系列操作,如删除,修改.现在以删除为例说明问题. 实现方式: 使用button,在onclick中调用js函数,js函数中传递参数如 ...

  2. android开发之SnackBar的使用

    SnackBar是一个类似于Toast的东西,它也有显示时长,但是比Toast更加灵活,同时,我们还可以给SnackBar设置点击事件,那么我们今天就来看看怎么用吧! 先来一张效果图: 这种效果大家可 ...

  3. Margin和Padding之间的区别

    margin ,padding body他们之间的区别就是 margin表示的是外边框的距离 padding表示的是内边框的距离 body表示的边框的距离

  4. verilog中的task用法

    任务就是一段封装在“task-endtask”之间的程序.任务是通过调用来执行的,而且只有在调用时才执行,如果定义了任务,但是在整个过程中都没有调用它,那么这个任务是不会执行的.调用某个任务时可能需要 ...

  5. android studio 导入的项目有乱码-笔记2

    如果导入的项目原本就是UTF-8.且android studio编码设置为UTF-8就不会乱码.这种情况多是导入的原项目编码为GBK. 解决方法:在android studio 右下角,切换编码为GB ...

  6. CSS常见选择器

    一.元素选择器 p,html,h1, h2 1.多个元素一起设置同一种风格, 则用逗号“,”隔开(选择器分组) 2.通配符选择,  *{Color:red}  表示文档中所有元素都为红色 二.类选择器 ...

  7. NSArray 常用的一些方法

    - (NSUInteger) count; 返回数组中元素个数 - (id)objectAtIndex:(NSUInteger)index; 返回一个id类型的数组指定位置元素 - (id)lastO ...

  8. AudioStreamer使用之快速点击下/上一首按钮,音频会重复的问题解决。

    针对此问题,我的做法是在AudioStreamer.h文件新加入一个属性 @property (nonatomic,strong) NSURL *musicUrl; 和一个单例方法: +(id)sha ...

  9. 近期专案PM相关收获

    1, 厚黑学讲的有道理, 坏人? 为什么占便宜., 好人为什么当不了坏人是有一定道理的.     -- 作为PM,能力大小居然都能胜任,从这一点上对组员不负责,如下种种都算有则改之无则加勉.      ...

  10. windows下ipython的tab补全,只需安装pyreadline即可.

    运行ipython提示缺失模块 在windows下安装readline失败. 根据提示访问 https://urllib3.readthedocs.org/en/latest/security.htm ...