Time Limit: 2 second(s) | Memory Limit: 32 MB |
You are given the task to design a lighting system for a huge conference hall. After doing a lot of calculation & sketching, you have figured out the requirements for an energy-efficient design that can properly illuminate the entire hall. According to your design, you need lamps of n different power ratings. For some strange current regulation method, all the lamps need to be fed with the same amount of current. So, each category of lamp has a corresponding voltage rating. Now, you know the number of lamps and cost of every single unit of lamp for each category. But the problem is that you are to buy equivalent voltage sources for all the lamp categories. You can buy a single voltage source for each category (each source is capable of supplying to infinite number of lamps of its voltage rating) and complete the design. But the accounts section of your company soon figures out that they might be able to reduce the total system cost by eliminating some of the voltage sources and replacing the lamps of that category with higher rating lamps. Certainly you can never replace a lamp by a lower rating lamp as some portion of the hall might not be illuminated then. You are more concerned about money-saving rather than energy-saving. Find the minimum possible cost to design the system.
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing an integer n (1 ≤ n ≤ 1000). Each of the next n lines contains four integers V_{i}, K_{i}, C_{i} and L_{i }(1 ≤ V_{i} ≤ 10^{5}, 1 ≤ K_{i} ≤ 1000, 1 ≤ C_{i} ≤ 10, 1 ≤ L_{i} ≤ 100). Here the integers in i^{th} line have the following meaning.
1. V_{i} means the voltage rating,
2. K_{i} means the cost of a voltage source of this category,
3. C_{i} means the cost of a lamp of this category and
4. L_{i} means the number of required lamps of this category.
You can assume that the voltage rating for the categories will be distinct.
For each case, print the case number and the minimum possible cost to design the system.
Sample Input |
Output for Sample Input |
1 3 100 500 10 20 120 600 8 16 220 400 7 18 |
Case 1: 778 |
Developed and Maintained by
JANE ALAM JAN |
Copyright © 2012
LightOJ, Jane Alam Jan |