### Problem Statement

The process of producing silicon chips is long and complex. Special care must be taken when cutting a delicate silicon disk. A contractor has hired you to work just in this area. As it turns out, his cutting machine can make only one type of cut: one that starts in the center of the disc, ends at the perimeter and has a length equal to the radius. Such a cut can easily ruin the entire piece being cut. Because of this, the area of the piece being cut is also the price of the cut. Consider an example where you must cut a disk whose area is 100 into 3 pieces whose areas are 33%, 33% and 34% of the disk. The best way to cut them is by first making two cuts around the 34% piece, which costs 100 units per cut. Then make a single cut on the remaining piece of size 66 to get two 33% pieces, which costs 66 units. Thus, the minimum cost would be 266 units of money.

Write a method named minCost that takes an int area and an int[] percent, and returns the minimum cost of cutting a disk of size area into different pieces with sizes from percent. Note that the order of the elements of percent is unimportant, as you only need to achieve the required percentages.

### Definition

 Class: DiskCut Method: minCost Parameters: int, int[] Returns: double Method signature: double minCost(int area, int[] percent) (be sure your method is public)

### Notes

-Your return value must have a relative or absolute error less than 1e-9.

### Constraints

-area will be between 1 and 1000, inclusive.
-percent will have between 2 and 50 elements, inclusive.
-Each element in percent will be between 1 and 100, inclusive.
-The elements in percent will sum up to 100.

### Examples

0)

 `4` `{25,25,25,25}`
`Returns: 12.0`
 The best way to cut these pieces is by first making two cuts, resulting in two 50% pieces. Then, cut each piece in half. All this costs just 12.0 units.
1)

 `5` `{20,20,20,20,20}`
`Returns: 17.0`
2)

 `1` `{10, 40, 30, 20}`
`Returns: 2.9`

#### Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=3936

#### Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=6532&pm=3936

ValD

#### Testers:

PabloGilberto , lbackstrom , brett1479

#### Problem categories:

Dynamic Programming, Simple Math