Sum of Squares
Some natural numbers, such as , can be expressed as the sum of two squares of natural numbers: . Others, like , cannot be written in this form. Some natural numbers, like , can be expressed in this form in more than one way: .
Problem:
Develop a program in one of the IOI languages that reads some natural numbers and finds in how many different ways each of them can be written as the sum of two squares of natural numbers.
Input Files:
The input files named twosqr.in are text files with the following structure: The first line contains exactly one natural number T , the number of numbers that will follow. lines follow, each containing exactly one natural number Ν .
Output Files:
The output files named twosqr.out are text files with the following structure: They have exactly lines, each containing an integer: the number of ways in which the corresponding input number can be written as the sum of two squares of natural numbers.
Example of Input - Output Files:
STDIN (twosqr.in)
6
17
42
65
0
1025
203125
STDOUT (twosqr)
1
0
2
1
3
7
Maximum Execution Time: 1 sec
Comments