402215: GYM100702 C Runaway Quail

Memory Limit:1024 MB Time Limit:10 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Runaway Quailtime limit per test10 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Oh no - your N pet quail have all gotten loose! You are currently at position 0 on a line; the i-th quail starts off at some nonzero integer (positive or negative) position Pi on that line, in meters, and will continuously run away from you at a constant integer speed of Si meters per second. You can run at a constant integer speed of Y meters per second, and can change direction instantaneously whenever you want. Note that quail constantly run away from you even if you are not running toward them at the time. Whenever you occupy the same point as a quail, that quail is caught (this takes no additional time).

What is the minimum number of seconds it will take you to catch all of the quail?

Input

The first line of the input gives the number of test cases, T (1 ≤ T ≤ 100). T test cases follow. Each begins with one line with two space-separated integers Y (2 ≤ Y ≤ 1000), your speed, and N (1 ≤ N ≤ 500), the number of quail, and is followed by two more lines with N space-separated integers each. The first of these gives the positions Pi (1 ≤ |Pi| ≤ 107) of the quail, and the second gives the speeds Si (1 ≤ Si < Y).

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 minimum number of seconds needed to catch all the quail.

y will be considered correct if it is within an absolute or relative error of 10 - 6 of the correct answer.

ExamplesInput
2
4 3
-3 -6 -9
3 2 1
2 2
1 -1
1 1
Output
Case #1: 3.00000000000000000
Case #2: 5.00000000000000000
Note

In Case #1, you can run to the left and catch all three quail at the same time, 12 meters to the left of the starting position, which takes 3 seconds.

In Case #2, one optimal strategy is to run to the left until the second quail is caught at -2 m, which takes one second, and then run to the right in pursuit of the first quail, which you will catch at 6 m, taking four more seconds.

加入题单

算法标签: