LightOJ 1317
You probably have played the game "Throwing Balls into the Basket". It is a simple game. You have to throw a ball into a basket from a certain distance. One day we (the AIUB ACMMER) were playing the game. But it was slightly different from the main game. In our game we were N people trying to throw balls into M identical Baskets. At each turn we all were selecting a basket and trying to throw a ball into it. After the game we saw exactly S balls were successful. Now you will be given the value of N and M. For each player probability of throwing a ball into any basket successfully is P. Assume that there are infinitely many balls and the probability of choosing a basket by any player is 1/M. If multiple people choose a common basket and throw their ball, you can assume that their balls will not conflict, and the probability remains same for getting inside a basket. You have to find the expected number of balls entered into the baskets after K turns.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing three integers N (1 ≤ N ≤ 16), M (1 ≤ M ≤ 100) and K (0 ≤ K ≤ 100) and a real number P (0 ≤ P ≤ 1). P contains at most three places after the decimal point.
Output
For each case, print the case number and the expected number of balls. Errors less than 10-6 will be ignored.
Sample Input
2
1 1 1 0.5
1 1 2 0.5
Sample Output
Case 1: 0.5
Case 2: 1.000000
程序分析:
首先我们要知道每一次扔的时候,0个人扔进的概率,1个人扔进的概率….
由于最后不关心M个篮子里球的具体情况,所以M其实没有什么用
只要区分扔不扔进去,至于扔到哪个篮子不管
dp[i][j]表示到第i轮,篮子里有j个球的概率
最后答案就是Σi?dp[k][i]
程序代码:
#include<iostream>
#include<cstdio>
using namespace std; int main()
{
int t,n,m,k,ans=;
double p;
cin>>t;
while(t--)
{
cin>>n>>m>>k>>p;
printf("Case %d: %.6lf\n",ans++, k*n*p);
}
return ;
}
LightOJ 1317的更多相关文章
- ACM第六周竞赛题目——A LightOJ 1317
A - A Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status P ...
- lightOJ 1317 Throwing Balls into the Baskets
lightOJ 1317 Throwing Balls into the Baskets(期望) 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/ ...
- 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 Throwing Balls into the Baskets 期望
题目大意:有N个人,M个篮框.K个回合,每一个回合每一个人能够投一颗球,每一个人的命中率都是同样的P.问K回合后,投中的球的期望数是多少 解题思路:由于每一个人的投篮都是一个独立的事件.互不影响.所以 ...
- KUANGBIN带你飞
KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题 //201 ...
- kuangbin 带你飞 概率期望
正推不行就逆推! 经典问题:生日悖论 换成其互斥事件:m个人, 每个人生日都不相同的概率 ≤ 0.5 时最小人数. 这就是邮票收集问题的变形:每个邮票至少出现一次的概率 小于等于 0.5 邮票收集问题 ...
- [kuangbin带你飞]专题1-23题目清单总结
[kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 Fli ...
- ACM--[kuangbin带你飞]--专题1-23
专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find T ...
随机推荐
- MD5 加密 以及 加盐加密
这是MD5加密 - (NSString *)MD5Hash { const char *cStr = [self UTF8String]; unsigned char result[16]; CC_M ...
- nyoj 138 找球号(二)(哈希)
题目:nyoj——138 /*** 哈希求解...采用链表保存 插入时,可以去除重复 查找 找到该组,然后在改组的查找 当这个组不存在时或是没有找到时是 NO 其他是YES 1e6+1 时间最短 */ ...
- PADS LAYOUT到底怎么走线
PADS LAYOUT走线,是不是转角要自己手动慢慢转角啊?不能像PROTEL中那样自动转角吗 自己手动转角老是转不好,出现许多线头,对不齐,是不是我操作有误啊 走线的过程中,可以试试这个,切换端点. ...
- 转:CSS Overflow 属性
原文:CSS Overflow 属性译自:The CSS Overflow Property版权所有,转载请注明出处,多谢!! 根据CSS的盒模型概念,页面中的每个元素,都是一个矩形的盒子.这些盒子的 ...
- Java知识点复习
总结下java的知识点 final 关键字-方法:不能被子类重写(override)-变量:不能被修改-类:不可以被继承,派生子类 finally 关键字与try/catch语句配合使用,即使有异常抛 ...
- 如何修改MFC发布程序的图标
(1)第一种方法,直接替换工程路径下面res下面的ico图标,然后重新编译,一般需要重启系统才会生效: (2)第二种方法,在VS工程资源预览窗口的ICO下增加一个ico资源,名为IDR_ICON1,然 ...
- radio与checkbox的选中事件
<一>判断checkbox的选中事件 var result=$(this).find("input[type='checkbox']").prop("chec ...
- 第二天(CSS 选择器)
1.常用的CSS选择器 类型选择器: 例如: p { color : red ; } 后代选择器: 例如: h2 span { font-weight : bold ; ...
- poj 3243 Clever Y 高次方程
1 Accepted 8508K 579MS C++ 2237B/** hash的强大,,还是高次方程,不过要求n不一定是素数 **/ #include <iostream> #inclu ...
- 高质量程序设计指南C/C++语言——C++/C常量(2)