Main page Problems Volumes Ranking Mess Wiki Help News

Square Root

Volumes:   Simple Math

Many mathematical problems are solved in programming not precisely, but approximately, by several computations of the result, each of which is more and more close to the goal.

Let us practice the method of approximate calculation of the square root. Refer to Square Root Approximation article for details on the Heron's Method.

You will be given values for which to perform calculations and number of steps to perform.
Use r = 1 at the beginning, and output resulting approximation.

Input data will have the number of test-cases in first line. Next lines will contain test-cases themselves, each containing the value for which square root should be calculated and the number of calculation steps.
Answer should contain calculated approximations for each case, separated by space. For example:

input data:
3
150 0
5 1
10 3

answer:
1 3 3.196
You need to login to get test data and submit solution.