Description
You probably has played the game "throwing Balls into the basket". It's a simple game. You had to throw a ball into a basket from a certain distance. One day we (the Aiub Acmmer) were playing the game. But it is slightly different from the main game. In our game we wereNPeople trying to throw balls intoMIdentical baskets. At the turn we all were selecting a basket and trying to throw a ball into it. After the game we saw exactlySBalls were successful. Now you'll be given the value ofNandM. For each player probability of throwing a ball to any basket successfully areP. Assume that there be infinitely many balls and the probability of choosing a basket by any player is1/m.If multiple people choose a common basket and throw their ball, you can assume that their balls would 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 afterKTurns.
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 numberp (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 than10-6 'll be ignored.
Sample Input
2
1 1 1 0.5
1 1 2 0.5
Sample Output
Case 1:0.5
Case 2:1
Test instructions: N personal m basket each round each one can choose M basket in a throw ball in the probability of throwing in the ball after the K-wheel all the number of baskets inside the expected thinking: according to the desired definition and the number of baskets regardless, because the problem hypothesis does not affect, the result is n*k*p. Code:
#include <cstdio>using namespace Std;int main () { int T; int casex=1; Double n,m,k,p; Double ans; scanf ("%d", &t); while (t--) { scanf ("%lf%lf%lf%lf", &n,&m,&k,&p); ans=n*k*p; printf ("Case%d:%lf\n", Casex++,ans); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Light OJ 1317