#Lutece3306. Extended Monty Hall Problem
Extended Monty Hall Problem
Description
There're doors on the stage, exactly one car is behind one of the doors. A game with the above setting is played on the stage.
The game has turns. At the beginning of each turn, player Antimo51 is supposed to choose one of the closing doors without opening it and the host will open some doors other than that door. Specifically, in the -th turn of the game, the host will open doors that are not opened, not chosen, and not in front of the car. Note that a door will not be closed again once it is opened. At the end of each turn, Antimo51 can choose to terminate the game. If so, he can choose a door (which can be the same as one of those chosen in the previous turns) and get the prize behind it. If all turns are played, Antimo51 must choose a door and get the prize behind it.
The host will try to minimize Antimo51's probability of getting the car. Please find out a strategy for Antimo51 that maximizes that probability. Output the maximum probability that you can get.
Input
The first line contains two integers and , denoting the number of doors and the number of turns.
The second line contains integers, where the -th integer denotes , the number of the doors to be chosen by the host in the -th turn.
It's guaranteed that .
Output
Output the answer as a minimal fraction.
Specifically, output two integers and separated by a space, denoting that the answer equals . The numbers and must satisfy that and , where denotes the greatest common divisor of and . Note that, when the answer is an integer, although , you should still output .
Samples
3 1
1
2 3
4 1
2
3 4
6 2
2 1
5 12
Note
In the first example, Antimo51 should choose the door other than the one chosen at the beginning, resulting in a probability of .
Resources
电子科技大学第十三届 ACM 趣味程序设计竞赛