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 的格子里,每个格子都有相应的金币数,走到相应格子的话,就会得 ...
随机推荐
- xcode中自定义log打印
打印内容包括 在哪个文件中 ? 在哪个方法中? 将要执行什么操作? // 此打印实现前提: // 1.在.pch文件中实现自定义log打印方法,log名换为LCLog // 2.定义一个宏obje ...
- root连接ubuntu18.04“拒绝访问”的解决方法
1.设置root账户 sudo passwd root 2.ssh远程登陆拒绝访问:修改SSH配置文件 sudo vim /etc/ssh/sshd_config 找到并用#注释掉这行:PermitR ...
- ps---图层,移动工具
1.移动图层从一个文件到另一个文件相当于复制,如果俩文件大小相同,开始移动后,按下shift键,可保持原来位置.若不相同,拖拽后,按shift,则会自动居中.如果目标文档包含选区,会到选区的中央. 2 ...
- windows 上使用virtualenv进行python多版本转换
近期因为需要在python2.7和Python3.6上进行工作学习,可是笔记本只配置了python3.6环境. 所以打算使用virtualenv这个强大的工具进行多版本转换: 一.首先,默认已经配置好 ...
- LeetCode(82)Remove Duplicates from Sorted List
题目 Given a sorted linked list, delete all duplicates such that each element appear only once. For ex ...
- UVa 12118 检查员的难题 (dfs判连通, 构造欧拉通路)
题意: 分析: 欧拉通路:图连通:图中只有0个或2个度为奇数的结点 这题我们只需要判断选择的边构成多少个联通块, 再记录全部联通块一共有多少个奇度顶点. 然后我们在联通块中连线, 每次连接两个联通块就 ...
- github私有库购买信息
github私有库购买信息 一年84美元. 换算成人民币是:532元. 话说其他开发者都买了么?
- zoj 2736 Daffodil number
Daffodil number Time Limit: 2 Seconds Memory Limit: 65536 KB The daffodil number is one of the ...
- java常见问题集锦
Eclipse 编译错误 Access restriction:The type *** is not accessible due to restriction on... 解决方案 Eclipse ...
- Exact Change(01背包)
描述 Seller: That will be fourteen dollars. Buyer: Here's a twenty. Seller: Sorry, I don't have any ch ...