#P13335. [GCJ 2012 Finals] Twirling Towards Freedom

    ID: 15201 远端评测题 3000~6000ms 1024MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学计算几何2012Special Judge凸包旋转卡壳Google Code Jam

[GCJ 2012 Finals] Twirling Towards Freedom

题目背景

"I say we must move forward, not backward; upward, not forward;
and always twirling, twirling, twirling towards freedom!"
— Former U.S. Presidential nominee Kodos.

题目描述

After hearing this inspirational quote from America's first presidential nominee from the planet Rigel VII, you have decided that you too would like to twirl (rotate) towards freedom. For the purposes of this problem, you can think of "freedom" as being as far away from your starting location as possible.

The galaxy is a two-dimensional plane. Your space ship starts at the origin, position (0,0)(0, 0). There are NN stars in the galaxy. Every minute, you can choose a star and rotate your space ship 90 degrees clockwise around the star. You may also choose to stay where you are.

How far away can you move from the origin after MM minutes?

The image illustrates the first 3 rotations for a possible path in sample case 1. Note that this path is not necessarily a part of any optimal solution.

输入格式

The first line of the input gives the number of test cases, TT. TT test cases follow, beginning with two lines containing integers NN and MM. The next NN lines each contain two integers, XiX_i and YiY_i, representing the locations of stars.

输出格式

For each test case, output one line containing "Case #xx: DD", where xx is the case number (starting from 1) and DD is the distance from the origin to the optimal final position. Answers with absolute or relative error no larger than 10610^{-6} will be accepted.

3
4
1
-2 4
1 -2
4 1
0 2
1
4
-5 0
2
5
-1 1
-2 2
Case #1: 6.3245553203
Case #2: 10.0000000000
Case #3: 6.3245553203

提示

Limits

  • 1T100;1 \leq T \leq 100;
  • 1000Xi1000;-1000 \leq X_i \leq 1000;
  • 1000Yi1000.-1000 \leq Y_i \leq 1000.
  • No two stars will be at the same location.
  • There may be a star at the origin.

Test set 1 (10 Pts, Visible Verdict)

  • Time limit: 30 3 seconds.
  • 1N10.1 \leq N \leq 10.
  • 1M10.1 \leq M \leq 10.

Test set 2 (39 Pts, Hidden Verdict)

  • Time limit: 60 6 seconds.
  • 1N5000.1 \leq N \leq 5000.
  • 1M108.1 \leq M \leq 10^8.