Power Eggs
Time limit1sMemory limit256 MB
Find the fewest egg drops in the worst case that pin down the highest safe floor for N floors and K eggs, or report Impossible past 32.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Binary search
- Solved
- No attempts yet
Problem
Benedict bought identical power eggs. He owns a building and suddenly wanted to drop the eggs from different floors. The building has floors, numbered through .
A power egg breaks only under one condition. There is a value such that an egg dropped from floor or higher breaks, and an egg dropped from floor or lower does not. is an integer between and .
Benedict may drop an egg from any floor he likes, as many times as he likes, until it breaks. An egg that survives can be dropped again, and a broken egg is gone for good. Find the smallest number of drops that pins down even in the worst case.
Take a building with floors and a single egg. Benedict has to try floor first, then floor if the egg survives, then floor if it still survives. With one egg he cannot skip a floor, so the worst case costs three drops.
Input
The first line has the number of test cases ().
Each of the next lines has the height of the building and the number of eggs , separated by a single space (, ).
Output
For each test case, print one line with the minimum number of drops needed to pin down .
If that number is greater than , print Impossible instead of a number. Benedict does not have the energy for that many drops.