题目链接

题意:

  有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. java11 Guava:谷歌开发的集合库

    Guava:谷歌开发的集合库,通过build path->Add External JARs 把guava.jar包加进去. 版本控制工具:.CVS .SVN .git 所以需要下载git客户端 ...

  2. Linux 普通用户su命令切换控制

    1.编辑配置文件/etc/pam.d/su .将下面配置文件"#“去掉: # auth           required        pam_wheel.so use_uid 改成 a ...

  3. ZooKeeper 分布式锁实现

    1 场景描述 在分布式应用, 往往存在多个进程提供同一服务. 这些进程有可能在相同的机器上, 也有可能分布在不同的机器上. 如果这些进程共享了一些资源, 可能就需要分布式锁来锁定对这些资源的访问. 2 ...

  4. (转)我所理解的OOP——UML六种关系

    原文地址:http://www.cnblogs.com/dolphinX/p/3296681.html 最近由于经常给公司的小伙伴儿们讲一些OOP的基本东西,每次草纸都被我弄的很尴尬,画来画去自己都乱 ...

  5. JS实现跳转到页面任何地方

    要实现两个内容: 1.从A页面跳转到B页面任何地方 方法:用id对要跳转的地方进行标记. 首先,在A页面可以设一个链接 <a href = "b.html#pos" targ ...

  6. 让你一分钟认识电子身份验证系统EID

    什么是EID eID是英文"Electronic Identity"的英文简称,中文名为"电子身份证"或"网络电子身份证",由公安部第三研究 ...

  7. Orchard 学习-手动安装Orchard

    通过Orchard zip 文件手动配置网站 这篇文章将引导你如果通过Zip文件来安装Orchard. 我们会使用三种不同的方法来承载Orchard: IIS. WebMatrix and IIS E ...

  8. Unity3D题目,Unity中利用GUI输出九九乘法表

    网上看到的这题,下面贴出源代码 using UnityEngine;using System.Collections; public class c99 : MonoBehaviour//C#脚本名: ...

  9. MVC 避免黄页

    可以使用HandleErrorAttribute 有两种方式可以使用它,在类或者方法的头上加 [HandleError] 这种直接在类或者方法上加[HandlerError]手动添加 另外一种方式是使 ...

  10. 封装一个ISortable接口

    using System;/// <summary>/// 排序规范/// </summary>/// <typeparam name="T"> ...