#Lutece1224. Walk Around The Campsite

Walk Around The Campsite

Migrated from Lutece 1224 Walk Around The Campsite

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Gan Jiang was one of Yu Zhou's friends but worked for Cao Cao. One day Gan Jiang visited Yu Zhou's army and would like to steal something from Yu Zhou's army in the midnight. Yu Zhou invited him to stay for the whole night and set up guards.

Gan Jiang saw there are NN forts numbered 00, 11, 22, \cdots, n1n-1 in Yu Zhou's army, the guards are connecting the neighbours forts, including (0,1)(0, 1), (1,2)(n2,n1)(1, 2)\cdots (n-2,n-1), (n1,0)(n-1,0) to form a simple polygon. Gan Jiang was in the fort 00 only allowed to walk towards the higher numbered forts in straight line. He was not allowed to go inside of the polygon even pass by other vertices, but he can go along the edges of the polygon, e.g, go from fort 2 to fort 3. When Gan Jiang arrived a fort, he could steal letters of value ViV_i. But walking makes him unhappy and for each unit length walking, he will get 11 unit of unhappiness, Gan Jiang could end this mission at any time and ride a horse back to Cao Cao.

title

Gan Jiang would like to make the total value of letters as big as possible, but make the unhappiness as low as possible. So his target is to make the total value of letters minus total unhappiness as big as possible. Help Gan Jiang to get it.

Input

The first line of the input gives the number of test cases, TT(1101\leq 10). TT test cases follow. Each test case starts with an integer NN(1N10001\leq N\leq 1000).

Each of the next NN lines consists of 33 float numbers with 44 digits after decimal point, xix_i, yiy_i(105xi,yi105-10^5\leq x_i, y_i\leq 10^5), ViV_i(0Vi1050\leq V_i\leq 10^5), (xi,yi)(x_i, y_i) represents the coordinate of fort ii and ViV_i represents the value of the letters in for ii.

Output

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 11) and yy is the maximal value of total value of letters minus total unhappiness. yy will be considered correct if it is within an absolute or relative error of 10410^{-4} of the correct answer.

Samples

3

4
0.0000 0.0000 0.0000
1.0000 0.0000 0.5000
1.0000 1.0000 2.0000
0.0000 1.0000 0.5000

5
0.0000 0.0000 0.0000
1.0000 1.0000 0.5000
2.0000 0.0000 2.0000
2.0000 2.0000 3.0000
0.0000 2.0000 0.0000

11
0.0000 0.0000 100.0000
1.0000 1.0000 100.0000
2.0000 0.0000 100.0000
2.0000 2.0000 100.0000
3.0000 2.0000 100.0000
3.0000 -2.0000 100.0000
1.0000 0.0000 100.0000
1.0000 -3.0000 100.0000
4.0000 -3.0000 100.0000
4.0000 4.0000 100.0000
0.0000 4.0000 100.0000
Case #1: 0.5000
Case #2: 1.0000
Case #3: 1070.3431

Resources

The 2015 China Collegiate Programming Contest