PDP-28 (2016) - Camp juniors - 2 (sumofcubes)

View as PDF

Submit solution

Points: 30 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

SUMOFCUBES

Some natural numbers, like 17, can be expressed as the sum of three cubes of natural numbers: 17 = 1^3 + 2^3 + 2^3. Others, like 42, cannot be written in this form. Some natural numbers, like 251, can be expressed in this form in more than one way: 251 = 1^3 + 5^3 + 5^3 = 2^3 + 3^3 + 6^3.

Write a program that reads some natural numbers and finds out how many different ways each of them can be written as the sum of three cubes of natural numbers.

Input

The first line of the input will contain the number T of numbers that will be given next. The following T lines will each contain exactly one natural number N_i.

Output

The output must consist of T lines, each of which must contain exactly one integer, the number of ways in which the corresponding number N_i of the input can be written as the sum of three cubes of natural numbers.

Constraints

1 \le T \le 10.000
0 \le N_i \le 1.000.000.000
Execution time limit: 1 sec.
Memory limit: 16 MB.

Example of Input - Output

STDIN (sumofcubes.in)

6
17
42
251
0
5104
1003

STDOUT (sumofcubes.out)

1
0
2
1
3
0

Example Explanation: The number 17 = 1^3+ 2^3+ 2^3 can be expressed in one way as the sum of three cubes. The number 251 = 1^3+ 5^3+5^3= 2^3+ 3^3+ 6^3 can be expressed in two ways as the sum of three cubes. The number 0 = 0^3+ 0^3+ 0^3 can be expressed in one way as the sum of three cubes. The number 5104 = 1^3+ 12^3+ 15^3= 2^3+ 10^3+ 16^3= 9^3+ 10^3+ 15^3 can be expressed in three ways as the sum of three cubes. Finally, the numbers 42 and 1003 cannot be expressed as the sum of three cubes.


Comments

There are no comments at the moment.