Throwing Balls into the Baskets LightOJ
来源:互联网 发布:雨露计划app软件 编辑:程序博客网 时间:2024/06/01 09:49
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
emmmm读了十几遍题目后,按着猜的题意交了一发a了才确定这是个巨sb的水题。
题意:有n个人去投m个篮子,有无限个球,每个人投中球的概率为P,每一轮每个人都选择一个球投一次,投向同一个篮筐的球互不影响。问经过k轮后的进球数量的期望是多少
思路:一轮进球的数量期望为n*p,k轮即为n*p*k。(所以那m个篮筐是干啥用的?。。。)
代码如下
#include<bits/stdc++.h>using namespace std;#define LL long long int main(){ int T; scanf("%d",&T); for(int cas=1;cas<=T;cas++) { int N,M,K; double P; scanf("%d%d%d%lf",&N,&M,&K,&P); printf("Case %d: %.7lf\n",cas,N*K*P); } return 0;}
- lightOJ 1317 - Throwing Balls into the Baskets
- lightOJ 1317 Throwing Balls into the Baskets
- LightOJ 1317 Throwing Balls into the Baskets
- lightoj 1317 Throwing Balls into the Baskets
- Throwing Balls into the Baskets LightOJ
- Throwing Balls into the Baskets LightOJ
- LightOJ - 1317 Throwing Balls into the Baskets 期望
- LightOJ 1317Throwing Balls into the Baskets(期望水题)
- LightOJ1317-Throwing Balls into the Baskets
- Light OJ 1317 Throwing Balls into the Baskets 概率DP
- LightOJ1317---Throwing Balls into the Baskets (概率dp)
- LightOJ 1064 Throwing Dice
- lightoj 1064 - Throwing Dice
- LightOJ 1064 Throwing Dice (DP)
- 【LightOJ 1064 】Throwing Dice + dp
- LightOJ 1064 Throwing Dice 概率DP
- LightOJ 1064 - Throwing Dice (dp)
- LightOJ 1064 - Throwing Dice(概率DP)
- Web Service (013---webservice使用Jquery、Ajax请求WebService)
- 文件的操作上传
- codeforces C. System Administrator 构造含割点的图
- 第九周周四总结
- 【Boost】boost::noncopyable介绍
- Throwing Balls into the Baskets LightOJ
- 计算机网络(四) --- 数据链路层
- 关于iOS11、iPhone X、Xcode9 适配详解
- Can't process attribute android:fillColor="@color/text_gray": references to other resources are not
- c++实现顺序表
- 10/21/22作业
- HAOI 2010 软件安装(Tarjan+树形dp)
- Web Service (014---webservice使用Jquery、Ajax请求WebService所遇到的跨域问题)
- java CommomUtils工具类