| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
From Pythagoras to ¡
Description There
was a footpath, leading across fields to New Southgate, and I used to
go there alone to watch the sunset and contemplate suicide. I did not,
however, commit suicide, because I wished to know more of mathematics. ¡ª Bertrand Russell Mathematics
is beautiful, isn¡¯t it? Well, I¡¯m sure you all know the famous
Pythagorean theorem. He found an amazing fact about triangles, that is
if the triangle has a right angle, the following relation holds: a2 + b2 = c2, where c is the length of the hypotenuse. However, Pythagoras told us nothing more about the generalization below: x2 + y2 = n, where n is an integer. It
is a natural tendency for mathematicians to solve whether an equation
has integer solutions or not. But for you, a future computer scientist,
will you also try to do some of the mathematicians¡¯ work? To simplify this problem, you are only required to find out whether the above equation x2 + y2 = n has integer solutions. Input The first line of the input is an integer T (T ¡Ü 50), and the following T lines have an integer n each. It is guaranteed that each n fits in signed 64-bit integer type. Output For each test case output ¡° Sample Input Sample Output Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2006 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator