Problem 1: Twenty Questions
In the game of twenty
questions I think of an item (like a
fish) from a set of N items, and you get to ask me at most twenty
questions that can only be answered yes or no to identify the item. For example, you might ask Is it
living? If I answer yes, then you
might ask, Does it have fur? If I
answer no, then you might then ask, Does it have fins? This continues until you either guess the
item (in which case you win), or youve asked twenty questions without identifying
the item (in which case I win).
With just 20 questions you
could identify any one of 524,288 items, assuming you can distinguish among
them by asking 19 yes/no questions and then with your 20th
question ask, Is it X? Of course it
might take fewer than 20 questions if you have a good idea about the identity
of the item, but in this problem well assume all the questions are used.
Suppose you could ask
questions that could be answered with more than just a yes or no. For example, suppose you could ask, Does it
weight less than, equal to, or greater than 10 pounds? This question has three possible
answers. Then how many questions would
you need to ask in order to distinguish among N items?
In this problem you will
be told how many different answers can be given to each of your questions, and
the number of items in the set of possible choices for the item. All you need to do is determine the maximum
number of questions that must be asked to identify the item. This assumes that your questions are chosen
in such a way as to divide the remaining candidates for the item into suitably
sized groups.
Input
There will be multiple
cases to consider. For each case there
will be two integers in the input. The
first integer, K, is the number
of possible answers to each question (no larger than 10). The second integer, N, is the number
of items in the set of possible choices (no larger than 2,147,483,647). A pair of zeroes will follow the last case.
Output
For each input case,
display a single line that looks like this:
N items, K answers per
question, M questions
where N and K
are the values from the input, and M is the maximum number of questions
required.
Sample Input
2
524288
3
524288
4
524288
3 9
10 1000
0 0
Expected Output
524288
items, 2 answers per question, 20 questions
524288
items, 3 answers per question, 13 questions
524288
items, 4 answers per question, 11 questions
9
items, 3 answers per question, 3 questions
1000
items, 10 answers per question, 4 questions