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个英文字母. 于是,刁钻的英语老师给他布置了一个 ...
随机推荐
- Linux-Apache+Mysql+PHP+PHPWind(重点Apache+PHP集成环境)
整理Apache+Mysql+PHP+PHPWind(Apache+PHP集成环境) 一.情况简述: 1.虚拟机VM上面CentOS 2.全部yum安装(yum安装与源码安装的安装路径不同) 二.操作 ...
- 6-10k招几个.NET开发工程师(工作地点:成都)
目前工作的公司是一家做新加坡公司在成都的研发中心,目前有个项目组在做电子医疗记录(EMR)软件系统,在新加坡卖得还不错,由于以前版本的技术有障碍(主要采用WPF技术),目前老板决定投资用比较主流的技术 ...
- Eclipse SVN冲突解决
基本原则是:每次提交前需要先和线上的对比,先把冲突解决掉,然后把线上的更新到本地,最后把本地的提交上去. 右键项目 -> Team -> 与资源库同步 在同步视图中选择Conflicts ...
- java中反射
Person.java===>>person.class ==>>jvm中的类加载器===>>class对象:代表内存中Person.class ==>> ...
- iosiOS 地图 自定义以及添加锚点
- (void)clickLongPress:(UILongPressGestureRecognizer *)longPress { CGPoint point = [longPress locati ...
- 备份/恢复SQLSERVER数据库,SQL一步实现
--备份SQL SERVER数据库 BACKUP DATABASE book09 TO DISK ='c:\abc.bak' WITH init --恢复SQL SERVER数据库USE MAST ...
- [微信开发利器]微信内移动前端开发抓包调试工具fiddler使用教程
[微信开发利器]微信内移动前端开发抓包调试工具fiddler使用教程 在朋友圈看到一款疯转的H5小游戏,想要copy,什么?只能在微信里打开?小样,图样图森破,限制了oauth.微信浏览器内打开, ...
- What is the behavior of lnk files?
I access a files which name is "abc.doc", no doubt a lnk file "abc.doc.lnk" show ...
- Unable to write inside TEMP environment path
安装PostgreSQL 9:Unable to write inside TEMP environment path 注册表:regedit HKEY_CLASSES_ROOT\.vbs,设置默认为 ...
- 最简洁粗暴版的虚拟用户配置FTP
最简洁粗暴版的虚拟用户配置FTP yum安装FTP: yum install vsftpd pam* db4* -y 设置为系统服务:chkconfig –level 35 vsftpd on 2.v ...