[Solution] Tea with Tangerines Codeforces Solution
There are pieces of tangerine peel, the -th of them has size . In one step it is possible to divide one piece of size into two pieces of positive integer sizes and so that .
You want that for each pair of pieces, their sizes differ strictly less than twice. What is the minimum possible number of steps needed to satisfy the condition?
The first line of the input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains the integer ().
Then one line follows, containing integers ().
For each test case, output a single line containing the minimum number of steps.
In the first test case, we initially have a piece of size , so all final pieces must have size . The total number of steps is: .
In the second test case, we have just one piece, so we don't need to do anything, and the answer is steps.
In the third test case, one of the possible cut options is: . You can see this option in the picture below. The maximum piece has size , and it is less than times bigger than the minimum piece of size . steps are done. We can show that it is the minimum possible number of steps
No comments:
Post a Comment