Under construction

Still being built. Things may change

Bullseye

Interview

Time limit5sMemory limit512 MB

Summary
Starting from a white circle of radius r, count how many alternating 1cm black rings the paint budget can complete.
Level

Medium5 of 10

Topics
Binary search, Math
Solved
No attempts yet

Problem

Maria works for a company that manufactures black-and-white bullseyes. A bullseye is a stack of rings formed between concentric circles, circles that share one center, and it usually represents an archery target.

Maria has tt millilitres of black paint, and she draws rings of thickness 1cm with it. A ring of thickness 1cm is the space between two concentric circles whose radii differ by 1cm.

Maria draws the first black ring around a white circle of radius rr cm. After that she repeats the following process for as long as she has enough paint.

  1. Maria imagines a white ring of thickness 1cm around the last black ring.
  2. She draws a new black ring of thickness 1cm around that white ring.

Each white ring is only the empty space left between two black rings.

A disk of radius 1cm has area π\pi cm2^2. One millilitre of paint covers area π\pi cm2^2. Find the maximum number of black rings Maria can draw. Note these two conditions.

  • Maria draws complete rings only. If the paint left is not enough for one whole black ring, she stops immediately.
  • 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 one space.

Constraints

  • 1≤T≤10001 \le T \le 1000
  • 1≤r≤10181 \le r \le 10^{18}
  • 1≤t≤10181 \le t \le 10^{18}
  • 2r+1≤t2r + 1 \le t, so at least one black ring always fits.

Output

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

Examples1

  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