Skyland
Time limit5sMemory limit64 MB
Choose nonnegative island heights totaling at least H to minimize linear plus pairwise absolute-difference costs, and report each minimum as a reduced fraction.
Problem
Somewhere in the sky the KM kingdom built floating islands with its advanced technology. The islands are numbered from to .
King Kitamasa picks the altitude of every island freely among the non-negative real numbers, as long as the altitudes add up to at least . Lifting island to altitude costs . The islands also talk to each other, so island and island cost another .
Energy prices went up, so the king wants the total cost
to be as small as possible. You are the court programmer, so compute that minimum. It is always a rational number.
Input
The input holds several test cases. The first line of a test case has two integers and separated by one space (, ). The second line has integers (). Each of the next lines has integers (). Always and .
A line with two zeros follows the last test case. There are at most test cases.
Output
For each test case print one line in the form Case x: p/q. Here is the test case number counting from , and is the minimum total cost written as a reduced fraction, with and . An integer minimum is printed as v/1. For example, a minimum of is printed as 2/1 and a minimum of is printed as 35/2.