当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3209:From Pythagoras to …

题目描述

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.

输入解释

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.

输出解释

For each test case output “YES” or “NO” indicating that the equation has or doesn’t have integer solutions, respectively.

输入样例
1
0
输出样例
YES

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3209

最后修改于 2020-10-29T06:55:53+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 131072