시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB17105100.000%

문제

Oh no -- your N pet quail have all gotten loose! You are currently at position 0 on a line; the ith 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 Simeters 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?

입력

The first line of the input gives the number of test cases, TT test cases follow. Each begins with one line with two space-separated integers Y, your speed, and N, 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 of the quail, and the second gives the speeds Si.

Limits

  • 1 ≤ T ≤ 100.
  • 2 ≤ Y ≤ 1000.
  • -107 ≤ Pi ≤ 107; no Pi is 0.
  • 1 ≤ Si < Y.
  • 1 ≤ N ≤ 500.

출력

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. See the FAQ for an explanation of what that means, and what formats of real numbers we accept.

예제 입력 1

2
4 3
-3 -6 -9
3 2 1
2 2
1 -1
1 1

예제 출력 1

Case #1: 3.000000
Case #2: 5.000000

출처

Contest > Google > Code Jam > Google Code Jam 2015 > Round 3 C2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.