Algorithm title: 10491

Source: Internet
Author: User
Tags time limit

Problem H

Cows and Cars

Input:standard input

Output:standard output

Time Limit:4 seconds

In television contests, participants are often asked to choose one out of set of or doors for example, one or several of W Hich leads to different prizes. In this problem we'll deal with a specific kind of such a contest. Suppose you are given the following challenge by the contest presenter:

In front of your there are three doors. Two of them hide a cow, the other one hides your prize-a car.
After your choose a door, but before you open it, I'll give you a hint by opening one of the doors which hides a cow (i ' ll never open the door you have chosen, even if it hides a cow). You'll then be able to choose if you are want to keep your, or if you choice to the other wish unopened. You'll win whatever is behind the door your open.

In this example, the probability your have of winning the car is 2/3 (as hard as it's to believe), assuming you always SWI TCH your choice when the presenter gives your opportunity to does so (after he shows for you, a door with a cow). The reason of this number (2/3) is this-if your had chosen one of the two cows, you would surely switch to the car, since The presenter had shown you cow. If you are had chosen the car, you would switch to the remaining cow, therefore losing the prize. Thus, in two out of three cases you would switch to the car. The probability to-win if you had chosen to stick with your initial choice would-obviously is only 1/3, but that isn ' t imp Ortant for this problem.

In this problem, your are to calculate the probability your have of winning the car, for a generalization of the problem Abo Ve:

-The number of cows is variable

-The number of cars are variable (number of cows + number of cars = total number of doors)

-The number of doors hiding cows that presenter opens for your are variable (several doors may still Re given the opportunity to change your choice)

You are should assume that your always decide to switch your choice to all other's unopen doors after the presenter You are some doors with cows behind it.

Input

There are several test cases for your the to process. Each test case consists of the three integers on a line and separated by whitespace. Each line has the following format:

Ncows Ncars Nshow

Where Ncows is the number of doors with cows, ncars are the number of doors with cars and nshow are the number of doors the Presenter opens for you before your choose to switch to another unopen.

The limits for your program are:

1 <= ncows <= 10000

1 <= ncars <= 10000

0 <= Nshow < ncows

Output

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.