1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10491 - Cows and Cars
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1432
* @author Mitterreiter Christian
* @author Posselt Christian
* @version 1.0, 05/25/2011
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.832
*/


import java.util.Scanner;

public class Main {

public static void main(String[] args) {

int cow; //Anzahl der cows
int car; //Anzahl der cars
int show; //Anzahl aufgedeckter cows nach der Auswahl

Scanner s = new Scanner(System.in);

while(s.hasNext()) {

cow = s.nextInt();
car = s.nextInt();
show = s.nextInt();

//Ergebnisberechnung
System.out.printf("%.5f\n",1.0*(cow+car-1)/(cow+car)*car/((cow+car)-show-1));

//Die Wahrscheinlichkeit aus allen nicht aufgedeckten Toren ein Auto zu wählen unter
//der Bedingung, dass man bei der ersten Wahl kein Auto getroffen hat.


}
}
}

---------------------------------------------------------------------

1.
package contestVolumes.volume104;

import java.util.Scanner;

/**
* FWP, Ausgewhlte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10491 - Cows and Cars
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1432
*
* @author Siegfried Ippisch
* @version 1.0
*
* Method : -
* Status : Accepted
* Runtime: 1.872
*/
public class CowsAndCars {

public static void main(String[] args){
Scanner in = new Scanner(System.in);

while(in.hasNext()){
System.out.printf("%.5f\n",probabilityOfWinning(in.nextInt(),in.nextInt(),in.nextInt()));
}

in.close();
}

/**
* Idea:
*
* Case 1: first chose is a Car (carChance = cars/doors)
* -> remainingCars = cars - 1
* -> remianingCows = cows - show
* -> remainingDoors = doors -1 - show
* carWinChance = remainingCars/remainingDoors
*
* Case 2: first chose is a Cow (cowChance = cows/doors)
* -> remainingCars = cars
* -> remianingCows = cows - 1 - show
* -> remainingDoors = doors - 1 - show
* cowWinChance = remainingCars/remainingDoors
*
* total chance to win the car = carChance*carWinChance + cowChance*cowWinChance
*/
public static double probabilityOfWinning(double cows, double cars, double show){
double doors = cars + cows;
return (cars*(cars-1 + cows))/
(doors*(doors-1-show));
}

}