UVa 10491

From Algorithmist
Jump to navigation Jump to search

10491 - Cows and Cars[edit]

Summary[edit]

You are to find the probability of winning a car given that when you have picked a door, the contest presentor will open n doors with cows and you will choose another door.

Explanation[edit]

Looking at the above description, problem can be split into 2 subcases. 1. Finding P(cow 1st & car 2nd) 2. Finding P(car 1st & car 2nd)

Derive a formula and you will be able to solve this question. It is one of the shortest code I have seen.

Implementations[edit]

Input[edit]

2 1 1
5 3 2
2000 2700 900

Output[edit]

0.66667
0.52500
0.71056