A - A

Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu

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 N people trying to throw balls into 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 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 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

解题思路:

•题意:
•N个人, M个篮框,每个人投进球的概率是P。
•问每个人投K次, 总进球数的期望。
即 1 * C(1, 1) * 0.5^1 * 0.5 ^ 0
•每个人投球是相互独立的, 互不影响。求出一个人投K次的期望再乘以N即可。
•进球概率是P, 没有指定进哪一个篮框, 所以总的进球概率还是P(M* 1/M *P)
•每个人的进球数期望是:
•E = ∑(i * C(K, i) * P^i*(1 - P)^(K - i))
•最终答案 = E * N.
程序代码:
#include<cstdio>
using namespace std;
int main()
{
int t,Case=;
scanf("%d",&t);
while(t--)
{
double p,ans;
int m,n,k;
scanf("%d%d%d%lf",&n,&m,&k,&p);
ans=n*k*p;
printf("Case %d: %.6lf\n",++Case,ans);
}
return ;
}

ACM第六周竞赛题目——A LightOJ 1317的更多相关文章

  1. ACM第六周竞赛题目——B CodeForces 478B

    B - B Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  2. 1903021116—吉琛—Java第六周作业—类的定义

    项目 内容 课程班级博客链接 19信计班 这个作业要求链接 第六周作业链接 java面向对象的概念和定义 博客名称 学号-姓名-Java第六周作业-题目自拟 要求 每道题要有题目,代码(使用插入代码, ...

  3. 20145337 《Java程序设计》第六周学习总结

    20145337 <Java程序设计>第六周学习总结 教材学习内容总结 输入\输出 InputStream与OutputStream 从应用程序角度来看,如果要将数据从来源取出,可以使用输 ...

  4. 程序设计入门—Java语言 第六周编程题 1 单词长度(4分)

    第六周编程题 依照学术诚信条款,我保证此作业是本人独立完成的. 1 单词长度(4分) 题目内容: 你的程序要读入一行文本,其中以空格分隔为若干个单词,以'.'结束.你要输出这行文本中每个单词的长度.这 ...

  5. 《ACM国际大学生程序设计竞赛题解Ⅰ》——基础编程题

    这个专栏开始介绍一些<ACM国际大学生程序设计竞赛题解>上的竞赛题目,读者可以配合zju/poj/uva的在线测评系统提交代码(今天zoj貌似崩了). 其实看书名也能看出来这本书的思路,就 ...

  6. 201521123061 《Java程序设计》第六周学习总结

    201521123061 <Java程序设计>第六周学习总结 ***代码阅读:Child压缩包内 1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核 ...

  7. 201521123038 《Java程序设计》 第六周学习总结

    201521123038 <Java程序设计> 第六周学习总结 1. 本周学习总结 2. 书面作业 1.clone方法 1.1 Object对象中的 clone 方法是被protected ...

  8. 201521123122 《java程序设计》 第六周实验总结

    201521123122 <java程序设计>第六周实验总结 1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图,对面向对象思想 ...

  9. 201621123040《Java程序设计》第六周学习总结

    1.本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图或相关笔记,对面向对象思想进行一个总结 2.书面作业 2.1clone方法 2.1.1在te ...

随机推荐

  1. Bat命令知识[转]

    基础部分: 一.基础语法: 1.批处理文件是一个".bat"结尾的文本文件,这个文件的每一行都是一条DOS命令.可以使用任何文本文件编辑工具创建和修改. 2.批处理是一种简单的程序 ...

  2. 利用反射把数据集合转换成List

    ---ResultSet数据集 public static List toList(ResultSet rs, Class cls) { List list = new ArrayList(); tr ...

  3. ASP+MYSQL的配置及乱码解决

    TempStr = "driver={MySQL ODBC 3.51 Driver};database="&strDB&";server="&a ...

  4. NRPE: Unable to read output 问题处理总结

    自定义nagios监控命令check_disk_data,首先在nagios服务端command.cfg定义了#'check_disk_data' command definitiondefine c ...

  5. 在treeview外加一个滚动条的实现

    前台代码: <div style="overflow:auto;width:190px;height:280px;border:1px solid #336699;padding-le ...

  6. 如何获取App当前版本号

    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary]; NSString *currentVersion = [infoDic ...

  7. c# web 删除时弹出提示框

    方法1: 在控件中增加属性 <asp:Button ID="btnSub" runat="server" Text="提交" oncl ...

  8. 安卓开发service

    如果把Activity比喻为前台程序,那么service可以看做是一个后台程序.Service跟Activity一样也由Intent调用. 在工程里想要添加一个Service,先新建继承Service ...

  9. 转载-Linux下svn搭建配置流程

    Linux下svn搭建配置流程     一.    源文件编译安装.源文件共两个,为: 1.   下载subversion源文件 subversion-1.6.1.tar.gz http://d136 ...

  10. spl_autoload_register()和__autoload()

    关于spl_autoload_register()和__autoload() 看两者的用法: //__autoload用法 function __autoload($classname) {     ...