Under construction

Still being built. Things may change

Infinity Area

Interview

Time limit20sMemory limit1024 MB

Summary
Given R, A, B, sum the areas of circles whose radii alternate between multiplying by A and integer-dividing by B, until a radius reaches zero.
Level

Easy3 of 10

Topics
Simulation, Math
Solved
No attempts yet

Problem

Let us assume for the simplicity of this problem that the Infinity symbol is made of circles which touch externally at point SS as shown below, and let us call it the center of the infinity.

You are given three integers RR, AA, BB. You are currently at the center of the infinity. You first draw the right circle with radius RR and return to the center of the infinity. After that, you draw the left circle with radius equal to the radius of the last circle multiplied by AA. After reaching the center, you draw the right circle with radius equal to the radius of the last circle divided by BB (integer division). After reaching the center again, you draw the left circle with radius equal to the radius of the last circle multiplied by AA.

You keep drawing the left and right circles in this alternating order until the radius of the circle to be drawn becomes zero. Calculate the sum of areas of all the circles drawn. It is guaranteed that the process terminates after a finite number of steps.

Input

The first line of the input gives the number of test cases, TT. Each of the next TT lines contains three integers RR, AA, and BB, where RR is the radius of the first circle, and AA and BB are the parameters used to compute the radii of the subsequent circles.

Output

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the sum of areas of all the circles drawn until the radius of the circle to be drawn becomes zero.

yy is considered correct if it is within an absolute or relative error of 10−610^{-6} of the correct answer.

Examples1

  1. Example 1

    Input
    2
    1 3 6
    5 2 5
    
    Expected output
    Case #1: 31.415927
    Case #2: 455.530935