[Solution] Packing Books CodeChef Solution
Problem
Chef is moving to a new house!
Unfortunately, this means he now has to pack up his things so that they can be moved too. Currently, Chef is packing up his (rather impressive) book collection into cardboard boxes.
Chef has shelves of books, each of which contains exactly books. Each cardboard box can hold at most books. In order to not mess up the organization of the books, Chef will also ensure that books from different shelves will not be placed in the same box.
Under these conditions, what is the minimum number of boxes needed to pack all the books?
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of one line of input, containing three space-separated integers , and : the values described in the statement.
Output Format
For each test case, output on a new line one integer: the minimum number of boxes needed to pack all the books.
Explanation:
Test case : Each box can hold books, and each shelf has books. So, Chef needs only five boxes: one for each shelf.
Test case : Each box can hold books, and each shelf has books. So, Chef needs two boxes to hold all the books of one shelf (for example, one holding books and another one holding ). There are five shelves, so the total number of boxes needed is .
Test case : Each box can hold books, and each shelf has books. So, Chef needs two boxes to hold all the books of one shelf (for example, one holding books and another one holding ). There are two shelves, so the total number of boxes needed is .
Test case : Each shelf needs boxes to pack all its books. There are shelves, so the answer is .
No comments:
Post a Comment