#K3391. Monty Hall Simulation
Monty Hall Simulation
Monty Hall Simulation
In the Monty Hall problem, a contestant is presented with three doors, behind one of which there is a car (the prize) and behind the other two there are goats. The contestant initially picks one door. Then, the host, who knows what is behind each door, opens one of the other two doors, always revealing a goat. The contestant is then given the choice to stick with the original door or switch to the remaining unopened door.
This problem asks you to simulate the Monty Hall game for a given number of trials (N) (with (1 \leq N \leq 1{,}000{,}000)). For each trial, if the contestant sticks with the initial choice, they win only if the initial choice was the car; if they switch, they win only if the initial choice was not the car.
For reproducibility, use a fixed random seed (42) in your solution so that the simulation produces deterministic results. The output should display the number and percentage (formatted to two decimal places) of wins for both strategies.
inputFormat
The input consists of a single integer (N) from standard input, representing the number of simulation trials.
outputFormat
The output should contain two lines printed to standard output. The first line prints the result for sticking with the initial choice, and the second line prints the result for switching. Each line must follow the format:
Sticking wins: (%) Switching wins: (%)
where is formatted to two decimal places and the two percentages sum up to 100.00%.## sample
1
Sticking wins: 0 (0.00%)
Switching wins: 1 (100.00%)
</p>