参看资料:
https://blog.csdn.net/chy20142109/article/details/51774756
题目:
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
题目大意:
有n个人,m个篮筐,每个人一次投球进的概率为p,每一轮每个人都会投一次球,等概率选择每个篮筐而且之间互不影响。问 k 轮后进球数量的期望。
解题思路:
???
看到这道题之后很开心,这么水的吗?随即警惕,是不是又来骗我交 wa 了?然后就。。试试?恩。。过了。
一个人投篮的进球次数的期望为 p ;n 个投一轮 的进球次数期望 为 n*p ;n 个人投 k 轮的进球次数期望为 k*n*p;
实现代码:
#include<cstdio>
using namespace std;
int main(){
int t,n,m,k;
double p;
scanf("%d",&t);
for(int Case=1;Case<=t;Case++){
scanf("%d%d%d%lf",&n,&m,&k,&p);
printf("Case %d: %.8lf\n",Case,n*k*p);
}
return 0;
}