Bullseye
InterviewTime limit5sMemory limit512 MB
Maria starts from inner radius r with t millilitres of paint and paints alternating 1 cm black and white rings; find how many full black rings fit.
- Level
Medium5 of 10
- Topics
- Math, Binary search
- Solved
- No attempts yet
Problem
Maria paints bullseyes. A bullseye is a group of concentric rings, the black and white pattern used on an archery target.

Maria starts with millilitres of black paint and draws rings of thickness 1 cm. A ring of thickness 1 cm is the space between two concentric circles whose radii differ by 1 cm.
The first black ring goes around a white circle of radius cm. After that Maria repeats the following steps for as long as the paint lasts.
- She leaves a white ring of thickness 1 cm around the last black ring.
- She draws a new black ring of thickness 1 cm around that white ring.
A white ring is only the gap between two black rings.
A disk of radius 1 cm has area , and one millilitre of paint covers an area of . Find the largest number of black rings Maria can draw.
- Maria draws complete rings only. If the paint that is left is not enough for a whole black ring, she stops at once.
- The paint is always enough for at least one black ring.
Input
The first line contains the number of test cases . Each of the next lines contains two integers and separated by a space.
Constraints
Output
For each test case, print one line in the form Case #x: y, where is the case number starting from 1 and is the largest number of black rings Maria can draw.