Under construction

Still being built. Things may change

Ball Bearings

Time limit1sMemory limit128 MB

Summary
Given the inner diameter of an outer ring, the ball diameter, and the minimum gap between neighboring balls, find the maximum number of balls that fit.
Level

Easy3 of 10

Topics
Geometry, Math, Implementation, Binary search
Solved
No attempts yet

Problem

The Swedish company SKF makes ball bearings. A ball bearing is one of the two types of rolling (anti-friction) bearings; the other is the roller bearing.

Its function is to connect two machine members that move relative to one another so that the frictional resistance to motion is minimal. In many applications one member is a rotating shaft and the other a fixed housing. Each ball bearing has three main parts: two grooved, ring-like races and a number of balls. The balls fill the space between the two races and roll with negligible friction in the grooves. The balls may be loosely restrained and separated by a retainer (cage).

Presumably, the more balls you fit inside the outer ring, the smoother the ride will be, but how many can you fit? You are given the inner diameter of the outer ring, the diameter of the balls, and the minimum distance between neighboring balls. Compute the maximum number of balls that fit on the inside of the outer ring. Every ball must touch the outer ring.

Input

The first line contains a positive integer nn, the number of test cases. Each of the following nn lines describes one test case with three positive floating-point numbers DD, dd, ss: DD is the inner diameter of the outer ring, dd is the diameter of a ball, and ss is the minimum distance between neighboring balls. Every value lies in the range [0.0001,500.0][0.0001, 500.0].

Output

For each test case, output a single integer mm on its own line: the maximum number of balls that fit in the ball bearing under the constraints above. There will always be room for at least three balls.

Examples1

  1. Example 1

    Input
    2
    20 1 0.1
    100.0 13.0 0.2
    
    Expected output
    54
    20