Hdu 4254 A Famous Game (probability & Combinatorial mathematical formula)

Source: Internet
Author: User
Tags time limit

A Famous Game

http://acm.hdu.edu.cn/showproblem.php?pid=4254

Time limit:2000/1000 MS (java/others)

Memory limit:32768/32768 K (java/others)

Problem Description

Mr. B and Mr. M, like, with balls. They have many balls colored in blue and red. Firstly, Mr. B randomly picks up N balls out of the them and put them into a bag. Mr. M knows that there are n+1 possible situations in which the number of red balls be ranged from 0 to N, and we assume t He possibilities of the n+1 situations are the same. But Mr. M does not know which situation occurs. Secondly, Mr. M picks up P balls out of the bag and examines them. There are Q red balls and p-q blue balls. The question Is:if He picks up one more ball out of the bag, and what is the possibility so this ball is red?

Input

Each test case contains only one line with three integers n, P and Q (2 <= n <= 100,000, 0 <= P <= N-1, 0 < = Q <= P).

Output

For each test case, display a single line containing the case number and the possibility of the "next ball Mr. M picks out Is red. The number should is rounded to four decimal places.

Sample Input

3 0 04 2 1

Sample Output

Case 1:0.5000case 2:0.5000

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Source

Fudan Local Programming Contest 2012

I see this, but I think there's a problem with the formula.

Complete code:

/*0ms,260kb*/
  
#include <cstdio>
  
int main (void)
{
    int T = 0, N, p, q;
    while (~SCANF ("%d%d%d", &n, &p, &q))
        printf ("Case%d:%.4f\n", ++t, (q + 1.0)/(P + 2));
    return 0;
}

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.