LightOJ - 1317 Throwing Balls into the Baskets 期望
题目大意:有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 期望的更多相关文章
- lightOJ 1317 Throwing Balls into the Baskets
lightOJ 1317 Throwing Balls into the Baskets(期望) 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/ ...
- Light OJ 1317 Throwing Balls into the Baskets 概率DP
n个人 m个篮子 每一轮每一个人能够选m个篮子中一个扔球 扔中的概率都是p 求k轮后全部篮子里面球数量的期望值 依据全期望公式 进行一轮球数量的期望值为dp[1]*1+dp[2]*2+...+dp[ ...
- LightOj_1317 Throwing Balls into the Baskets
题目链接 题意: 有N个人, M个篮框, 每个人投进球的概率是P. 问每个人投K次后, 进球数的期望. 思路: 每个人都是相互独立的, 求出一个人进球数的期望即可. 进球数和篮框的选择貌似没有什么关系 ...
- ACM第六周竞赛题目——A LightOJ 1317
A - A Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status P ...
- LightOJ 1317 第八次比赛 A 题
Description You probably have played the game "Throwing Balls into the Basket". It is a si ...
- LightOJ 1317 第六周比赛A题
A - A Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Description Y ...
- LightOJ 1317
Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %lluDescription You probab ...
- LightOJ 1038 - Race to 1 Again(期望+DP)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1038 题意是:给你一个N (1 ≤ N ≤ 105) 每次N都随机选一个因子d,然后让 ...
- LightOj 1030 - Discovering Gold(dp+数学期望)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1030 题意:在一个1*n 的格子里,每个格子都有相应的金币数,走到相应格子的话,就会得 ...
随机推荐
- spring注解开发-声明式事务(源码)
1. 环境搭建与测试 1)导入相关依赖 数据源.数据库驱动.Spring-jdbc模块 <dependency> <groupId>org.springframework< ...
- (转)浅谈trie树
浅谈Trie树(字典树) Trie树(字典树) 一.引入 字典是干啥的?查找字的. 字典树自然也是起查找作用的.查找的是啥?单词. 看以下几个题: 1.给出n个单词和m个询问,每次询问 ...
- POJ-1190-生日蛋糕(深搜,剪枝)
生日蛋糕 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 23049 Accepted: 8215 Description 7月1 ...
- Centos7中 mysql5.7 用户 创建 、授权、远程登录
1.添加用户跟以往版本不同,MySQL5.7 mysql.user表没有password字段,这个字段改成了 authentication_string:这里我们使用命令进行创建用户: CREATE ...
- InnoDB体系架构总结(一)
缓冲池: 是一块内存区域,通过内存的速度来弥补磁盘速度较慢对数据库性能的影响.在数据库中读取的页数据会存放到缓冲池中,下次再读取相同页的时候,会首先判断该页是否在缓冲池中.对于数据库中页的修改操 ...
- tornado框架基础10-websocket
websocket 01 长轮询 在网页,我们经常扫码登录,结合之前的学习的知识点,来思考下,前端是如何知道用户在手机上扫码登录了呢? 长轮询:客户端不断的向服务器发送请求 缺点: \1. 开销大 \ ...
- 剑指Offer(书):剪绳子
题目:给你一根长度为n的绳子,请把绳子剪成m段,每段绳子的长度记为k[0],k[1]....,k[m].请问k[0]xk[1]x...,k[m]可能的最大乘积是多少.例如:长度为8剪成2 3 3 得到 ...
- 【01】魔芋使用MDN的一点点经验
[01]魔芋使用MDN的一点点经验 1,MDN地址: https://developer.mozilla.org/en-US/(下图) 2,建议看英文原文.因为中文翻译落后,并且有些翻译并 ...
- HDU1166-敌兵布阵,线段数模板题~~
敌兵布阵 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- bzoj 3223 文艺平衡树 splay 区间翻转
Tyvj 1728 普通平衡树 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 17715 Solved: 7769[Submit][Status][ ...