QOJ.ac

QOJ

Time Limit: 10 s - 39 s Memory Limit: 1024 MB Total points: 49

#5904. Twirling Towards Freedom

الإحصائيات

Problem

"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). There are N 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 M minutes?

problem_5904_1.png

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.

Input

The first line of the input gives the number of test cases, T. T test cases follow, beginning with two lines containing integers N and M. The next N lines each contain two integers, Xi and Yi, representing the locations of stars.

Output

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

Limits

Memory limit: 1GB.

1 ≤ T ≤ 100;

-1000 ≤ Xi ≤ 1000;

-1000 ≤ Yi ≤ 1000.

No two stars will be at the same location.

There may be a star at the origin.

Test set 1 (Visible Verdict; 10 Points)

Time limit: 30 6 seconds.

1 ≤ N ≤ 10.

1 ≤ M ≤ 10.

Test set 2 (Hidden Verdict; 39 Points)

Time limit: 60 12 seconds.

1 ≤ N ≤ 5000.

1 ≤ M ≤ 108.

Sample

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
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.