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 的格子里,每个格子都有相应的金币数,走到相应格子的话,就会得 ...
随机推荐
- android开发链接
http://blog.csdn.net/zz2043191420/article/details/47338591
- 深入理解typeof操作符
typeof可以检测数据的类型 typeof返回结果的其实是字符串:可以通过以下测试出来 console.log( typeof(typeof(a))); // string typeof返回的数据类 ...
- CreateProcess相关
CreateProcess不创建窗口执行: https://blog.csdn.net/rongwenbin/article/details/24422041 CreateProcess返回值: 执行 ...
- django踩坑
django输入localhost或者127.0.0.1可以进入,输入自己ip报错 结局方案: 首先找到自己的项目的setting.py文件 找到——> ALLOWED_HOSTS = [] 修 ...
- Linux内核学习总览
断断续续学习操作系统已经有大半年时间了,一直想系统地梳理一下. 正好借助<深入Linux内核架构> (Wolfgang Manuere 著,郭旭 译)汇总一下. 首先基础框架篇,Linux ...
- 转:使用 /proc 文件系统来访问 Linux 内核的内容
使用 /proc 文件系统来访问 Linux 内核的内容 https://www.ibm.com/developerworks/cn/linux/l-proc.html /proc 文件系统并不是 G ...
- Mysql ICP(翻译)
英文版原文链接 https://mariadb.com/kb/en/library/index-condition-pushdown/ ICP 全称 Index Condition Pushdown. ...
- 阿里云配置tomcat后不能访问问题
问题:使用阿里云centos 7.2配置好tomcat后,启动时间9分多钟,停在webapps下的manage这里近9分多钟 解决:进入 /usr/local/jdk1.8.0_144/jre/lib ...
- POJ 3122 pie (二分法)
Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have ...
- php file_get_contents json_decode 输出为NULL
解决办法一:不小心在返回的json字符串中返回了BOM头的不可见字符,某些编辑器默认会加上BOM头,如下处理才能正确解析json数据: $info = json_decode(trim($info,c ...