Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2011 /quals /double_squares.html
wjomlex's picture
2011 Problems
df6dd12 verified
raw
history blame contribute delete
930 Bytes
A double-square number is an integer <b>X</b> which can be expressed as the
sum of two perfect squares. For example, 10 is a double-square because 10 =
3<sup>2</sup> + 1<sup>2</sup>. Your task in this problem is, given <b>X</b>,
determine the number of ways in which it can be written as the sum of two
squares. For example, 10 can only be written as 3<sup>2</sup> + 1<sup>2</sup>
(we don't count 1<sup>2</sup> + 3<sup>2</sup> as being different). On the
other hand, 25 can be written as 5<sup>2</sup> + 0<sup>2</sup> or as
4<sup>2</sup> + 3<sup>2</sup>.<br/><br/>
<h3>Input</h3>
You should first read an integer <b>N</b>, the number of test cases. The next
<b>N</b> lines will contain <b>N</b> values of <b>X</b>.
<h3>Constraints</h3>
0 &le; <b>X</b> &le; 2147483647<br>
1 &le; <b>N</b> &le; 100
<h3>Output</h3>
For each value of <b>X</b>, you should output the number of ways to write
<b>X</b> as the sum of two squares.