Under construction

Still being built. Things may change

Treasure Hunt

Time limit1sMemory limit128 MB

Summary
Given a and b, find the shared limit of the arithmetic and harmonic mean iteration, which is sqrt(a b), printed to three decimals.
Level

Medium7 of 10

Topics
Math, Binary search
Solved
No attempts yet

Problem

On the way to school, Heehyun picked up a treasure map. The map said this.

  1. Let the coordinates of the school's main gate be (0,0)(0, 0).
  2. x0=ax_0 = a and y0=by_0 = b. (0<b≤a0 < b \le a)
  3. xn+1=xn+yn2x_{n+1} = \dfrac{x_n + y_n}{2}, yn+1=2xnynxn+yny_{n+1} = \dfrac{2 x_n y_n}{x_n + y_n}
  4. Keep following the trail and the treasure turns up!

The two sequences xnx_n and yny_n converge to one and the same value. That value is both the xx coordinate and the yy coordinate of the treasure. Help Heehyun and find where the treasure is.

Input

The first line contains two positive integers aa and bb, separated by a space. (0<b≤a≤10180 < b \le a \le 10^{18})

Output

Print the xx coordinate and the yy coordinate of the treasure on the first line, separated by a space.

Round both coordinates at the fourth digit after the decimal point and print exactly three digits after the decimal point. Keep trailing zeros. If the answer is the integer 66, write it as 6.000.

Examples5

  1. Example 1

    Input
    1 1
    
    Expected output
    1.000 1.000
    
  2. Example 2

    Input
    2 1
    
    Expected output
    1.414 1.414
    
  3. Example 3

    Input
    7 1
    
    Expected output
    2.646 2.646
    
  4. Example 4

    Input
    9 4
    
    Expected output
    6.000 6.000
    
  5. Example 5

    Input
    3 2
    
    Expected output
    2.449 2.449