SQRROOT - Square Root

no tags 

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

hide comments
blashyrkh: 2011-09-24 09:43:29

@Mehmet Inal: except int :)

Last edit: 2011-09-24 11:31:21
mehmetin: 2011-09-22 14:27:40

Do we need to use arrays and digit by digit computation in Python 3.0? 800 digit numbers overflow all number types, I guess?

Rubanenko: 2011-09-05 17:38:35

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:((

Daniel Ampuero: 2010-10-04 03:34:58

Very nice problem to be solved with Brainf**k and Whitespace! Enjoyment for the neurons.

hendrik: 2010-08-01 08:21:57

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.

Chandra Sekar: 2010-07-12 17:11:02

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
Bruno: 2010-07-04 22:31:26

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?

numerix: 2009-10-31 16:56:00

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
Shashwat Anand: 2009-09-17 11:34:31

Last edit: 2010-08-24 23:08:41

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