SQRROOT - Square Root

In this problem you have to find the Square Root for given number. You may assume that such a number exist and it will be always an integer.

Solutions to this problem can be submitted in C, C++, Pascal, Algol, Fortran, Ada, Ocaml, Prolog, Whitespace, Brainf**k and Intercal only.

Input

t - the number of test cases [t <= 50]
then t positive numbers follow, each of them have up to 800 digits in decimal representation.

Output

Output must contain exactly t numbers equal to the square root for given numbers. See sample input/output for details.

Example

Input:
3
36
81
226576

Output:
6
9
476

Added by:Roman Sol
Date:2004-12-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: BASH CSHARP CLPS LISP sbcl LISP clisp ERL HASK ICON JAVA JS-RHINO LUA NEM NICE PERL PHP PIKE PYTHON RUBY SCM qobi ST
Resource:ZCon 2005

hide comments
2011-09-24 09:43:29 blashyrkh
@Mehmet Inal: except int :)

Last edit: 2011-09-24 11:31:21
2011-09-22 14:27:40 mehmetin
Do we need to use arrays and digit by digit computation in Python 3.0? 800 digit numbers overflow all number types, I guess?
2011-09-05 17:38:35 Rubanenko
I use iterated binary search and my program works about 0.3 sec on ideone.com, but still have TLE. Help me please, coz I have no idea about the reason of this very TLE:((
2010-10-04 03:34:58 Daniel Ampuero
Very nice problem to be solved with Brainf**k and Whitespace! Enjoyment for the neurons.
2010-08-01 08:21:57 hendrik
You have two options doing this in Python:
1.) Use one of the built-in libraries. Then it is really an easy job as numerix stated.
2.) Implement your own algo
I have seen many submissions in Python failing. Obviously it is not sooo simple. Look at the input constraints. Make sure that you really can handle 800 digits numbers.
2010-07-12 17:11:02 Chandra Sekar
My python solutions are also getting NZEC's! Is a python solution VALID?

Anyone reply!

Edit: Got AC after a long struggle with Python! hurray to Babylonian algo!

Last edit: 2010-08-07 16:17:29
2010-07-04 22:31:26 Bruno
Hi all!!
I wrote a short quick script to handle this task in Python... However, I get NZEC error, which is akward as Python is not compiled... Are Python submissions still available to this task?
2009-10-31 16:56:00 numerix
Now you can do it in python, but that was only by accident and should be changed again as it is not really a task to solve that in python: 3 min of work and 5 lines of code ...

Last edit: 2010-01-03 21:55:44
2009-09-17 11:34:31 Shashwat Anand


Last edit: 2010-08-24 23:08:41
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.