Under construction

Still being built. Things may change

Bullseye

Interview

Time limit5sMemory limit512 MB

Summary
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 tt 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 rr cm. After that Maria repeats the following steps for as long as the paint lasts.

  1. She leaves a white ring of thickness 1 cm around the last black ring.
  2. 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 π cm2\pi\ \mathrm{cm}^2, and one millilitre of paint covers an area of π cm2\pi\ \mathrm{cm}^2. 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 TT. Each of the next TT lines contains two integers rr and tt separated by a space.

Constraints

  • 1≤T≤60001 \le T \le 6000
  • 1≤r≤10181 \le r \le 10^{18}
  • 1≤t≤2×10181 \le t \le 2 \times 10^{18}

Output

For each test case, print one line in the form Case #x: y, where xx is the case number starting from 1 and yy is the largest number of black rings Maria can draw.

Examples2

  1. Example 1

    Input
    5
    1 9
    1 10
    3 40
    1 1000000000000000000
    10000000000000000 1000000000000000000
    
    Expected output
    Case #1: 1
    Case #2: 2
    Case #3: 3
    Case #4: 707106780
    Case #5: 49
    
  2. Example 2

    Input
    1
    1 3
    
    Expected output
    Case #1: 1