Light OJ 1317

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.