QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 27

#14011. Vanishing Numbers

统计

There is a pool of numbers which are arbitrary decimal fractions from the interval (0, 1). In the first round of the game the middle third of the interval disappears, and the numbers from this interval are eliminated from the pool. In the next rounds the middle thirds of each of the remaining intervals disappear. In the first round the the interval [1/3, 2/3] is eliminated and in the second round the two intervals [1/9, 2/9] and [7/9, 8/9] are eliminated, and so on. The endpoints of each removed interval are removed as well.

Your role is to sort the pool of numbers in the order that they are eliminated. If some numbers are never eliminated, list them last. In case of a tie, list the smaller numbers first.

Input

The first line of input will contain T, the number of test cases. T test cases will follow. Each one will start with a line containing an integer N. N numbers will follow, one per line. Each number will start with "0.", followed by one or more decimal digits. Each number will be larger than zero and will not have any trailing zeros.

Output

For each test case, print the line "Case #x:", where x is the number of the test case, starting with 1. After that line, list the numbers, one per line, in order of elimination.

Limits

  • T ≤ 100
  • N ≤ 100

Small Dataset (10 points)

  • Each number will have at most 5 digits after the decimal point.

Large Dataset (17 points)

  • Each number will have at most 11 digits after the decimal point.

Example

Input

3
2
0.12
0.5
2
0.9
0.1
3
0.00449602349
0.10613259697
0.3283702389

Output

Case #1:
0.5
0.12
Case #2:
0.1
0.9
Case #3:
0.00449602349
0.10613259697
0.3283702389

In case #1, 0.5 is eliminated in the first round because it falls into the interval [1/3, 2/3]. After the first round, there are two intervals remaining: (0, 1/3) and (2/3, 1). The number 0.12 is eliminated in round 2 because it falls into the interval [1/9, 2/9].

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.