Stir-Frying Carrots
Time limit1sMemory limit128 MB
Find the fewest knife cuts that split carrots of given weights into real-valued pieces whose lightest-to-heaviest ratio exceeds T.
Problem
Carrots only fry evenly if they are all about the same size to begin with.
Sanggeun has carrots. One stroke of the knife splits a single carrot into two pieces: cutting a carrot of weight produces two carrots of weight and with . A piece does not have to weigh a whole number, and a piece that came out of an earlier cut can be cut again.
Sanggeun is afraid of the knife, so he wants to cut as few times as possible.
Given the weight of every carrot, write a program that finds the minimum number of cuts after which the weight of the lightest carrot divided by the weight of the heaviest carrot is greater than .
Input
The first line contains the ratio and the number of carrots . is given to two decimal places and satisfies . is a positive integer with .
The second line contains the carrot weights . Each is a positive integer smaller than .
Output
Print the minimum number of cuts needed for the weight of the lightest carrot divided by the weight of the heaviest carrot to become greater than . The answer is always smaller than .
To keep rounding error from turning a correct program into a wrong answer, only inputs that give the same answer for the ratio and for the ratio are used.