LightOJ 1317 第八次比赛 A 题
Description
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 Npeople 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). Pcontains 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
题目大意:
有n个人,m个篮筐,一共打了k轮,每轮每个人可以投一个球,每个球投进的概率都是p,求k轮后,投中的球的期望是多少?
分析:
因为每个人投进的概率都是相同的,所以期望也是相同的。因此只需要求出第一轮的期望就可以了,总期望=k*第一轮的期望。
代码如下:
#include <stdio.h>
int main()
{
int T,cas=;
scanf("%d",&T);
while(T--)
{
cas++;
double N,M,K;
double P,ans;
scanf("%lf%lf%lf%lf",&N,&M,&K,&P);
ans=N*P*K;
printf("Case %d: %lf\n",cas,ans);
}
return ;
}
LightOJ 1317 第八次比赛 A 题的更多相关文章
- LightOJ 1317 第六周比赛A题
A - A Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Description Y ...
- CodeForces 569A 第八次比赛 C题
Description Little Lesha loves listening to music via his smartphone. But the smartphone doesn't hav ...
- CodeForces 478B 第八次比赛 B题
Description n participants of the competition were split into m teams in some manner so that each te ...
- 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/ ...
- CSDN挑战编程——《金色十月线上编程比赛第二题:解密》
金色十月线上编程比赛第二题:解密 题目详情: 小强是一名学生, 同一时候他也是一个黑客. 考试结束后不久.他吃惊的发现自己的高等数学科目竟然挂了,于是他果断入侵了学校教务部站点. 在入侵的过程中.他发 ...
- lightoj 1148 Mad Counting(数学水题)
lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...
- UVA 10970 第一次比赛 D题 (后面才补的)
Mohammad has recently visited Switzerland. As heloves his friends very much, he decided to buy somec ...
- CSDN 四川大学线下编程比赛第二题:Peter的X
题目详情: http://student.csdn.net/mcs/programming_challenges Peter是个小男孩.他总是背不清26个英文字母. 于是,刁钻的英语老师给他布置了一个 ...
随机推荐
- tip浮动提示框
今天工作中碰到要弹出tip浮动提示框,如服务器控件的ToolTip属性. 通过GOOGLE搜到了一个很好用的tip浮动提示框:TipTip jQuery Plugin. 例子如下: <!DOCT ...
- Facebook 的系统架构(转)
来源:http://www.quora.com/What-is-Facebooks-architecture(由Micha?l Figuière回答) 根据我现有的阅读和谈话,我所理解的今天Faceb ...
- Linux逻辑卷管理器(LVM)
LVM基础 通过使用Linux的逻辑卷管理器(Logical Volume Manager, LVM),用户可以在系统运行时动态调整文件系统的大小,把数据从一块硬盘重定位到另一块硬盘,也可以提高I/O ...
- Android 之 下拉框(Spinner)的使用
下拉列表 Spinner. Spinner的使用,可以极大提高用户的体验性.当需要用户选择的时候,可以提供一个下拉列表将所有可选的项列出来.供用户选择. Demo如下,可以留作参考 一.使用数组作为数 ...
- java(POI):基于模版的Excel导出功能,局部列写保护总结
需求描述: 1.导出的Excel中部分列包含有下拉列表,并没有尝试过用代码实现这种功能,个人感觉比较棘手,故采用了模版的形式,直接导出数据到已经创建好的Excel模版中 2.Excel的第一列需要写保 ...
- 入门学习PHP之变量_1
1.函数里只能访问局部变量,不能访问全局变量,如果函数里需要访问全局变量则需要在变量前加global作用域,如下实例: <?php $x=5; $y=10; function myTest() ...
- 【转载】FPGA功耗的那些事儿
在项目设计初期,基于硬件电源模块的设计考虑,对FPGA设计中的功耗估计是必不可少的. 笔者经历过一个项目,整个系统的功耗达到了100w,而单片FPGA的功耗估计得到为20w左右, 有点过高了,功耗过高 ...
- POJ 1195
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 13774 Accepted: 6393 De ...
- 转载字典地址:http://blog.csdn.net/aladdinty/article/details/3591789
相关文章: http://www.360doc.com/content/13/1003/23/14070959_318861279.shtml http://www.360doc.com/conten ...
- VS2010 自动关闭的问题解决方法
分为如下几个解决方法: 没有安装VS2010的SP1,安装后,问题解决了 自定义设置,出现了不正确的情况,执行 devenv.exe /resetsettings 可以排除故障 使用 devenv.e ...