Painting Houses
InterviewTime limit1sMemory limit1024 MB
Given K, P, and X, find the minimum of m times X plus P times K divided by m over positive integers m, the number of painters.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Statement
You own a company that hires painters to paint houses. You can hire as many painters as you want. For each painter you hire, you pay X dollars, no matter how long that painter works on the house. You also pay a penalty of dollars if it takes days to finish painting the house. This penalty does not depend on the number of painters. Even if the time is not a whole number of days, you are penalized only for the exact time taken. All painters paint at the same rate. One painter finishes the house in days. painters cooperate so well that they finish in days. Find the minimum total cost, including the payment to the painters and the penalty, to get the house painted.
Input
The first line contains a single integer , the number of data sets. Each of the following data sets is one line with three space-separated integers , , and ().
Output
For each data set, print on a single line the minimum cost, rounded and displayed to exactly three decimal places.