Throwing Balls into the Baskets LightOJ - 1317 (巨水水题)

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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值