编程介的小学生 2017-09-24 14:37 采纳率: 20.5%
浏览 744
已采纳

Walk Around The Campsite

Problem 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 N forts numbered 0, 1, 2, …, n-1 in Yu Zhou's army, the guards are connecting the neighbours forts, including (0,1),(1,2)...(n−2,n−1),(n−1,0) to form a simple polygon. Gan Jiang was in the fort 0 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 Vi. But walking makes him unhappy and for each unit length walking, he will get 1 unit of unhappiness, Gan Jiang could end this mission at any time and ride a horse back to Cao Cao.

Figure 1: 3rd sample

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, T(1≤10). T test cases follow. Each test case starts with an integer N(1≤N≤1000. Each of the next N lines consists of 3 float numbers with 4 digits after decimal point, xi, yi(−105≤xi,yi≤105), Vi(0≤Vi≤105), (xi,yi) represents the coordinate of fort i and Vi represents the value of the letters in for i.

Output
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the maximal value of total value of letters minus total unhappiness. y will be considered correct if it is within an absolute or relative error of 10−4 of the correct answer.

Sample Input
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

Sample Output
Case #1: 0.5000
Case #2: 1.0000
Case #3: 1070.3431

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-12 15:47
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!