Subject requirement: the number of double supercubes is a positive integer that can be split into two different a ^ 3 + B ^ 3 methods, where, B is an integer and 0 <a <= B. For any specified int n, the number of all supercubes less than or equal to n is returned.
Definition
Class: TwiceSuperCubic
Method: count
Parameters: int
Returns: int
Method signature: int count (int n)
(Be sure your method is public)
Constraints
-N value range: 1 to 1,000,000,000 (inclusive)
Examples
0)
1
Returns: 0
1)
1729
Returns: 1
1729 = 1 ^ 3 + 12 ^ 3
1729 = 9 ^ 3 + 10 ^ 3
2)
475574
Returns: 27
Code
Public static class TwiceSuperCubic
{
Public static int count (int n)
{
Int r = 0;
Int f =-1;
If (n> 0 & n <= 1000000000)
{
For (int I = 1; I <= n; I ++)
{
F = 0;
Double sq = Math. Pow (I, 1f/3 );
For (int k = 1; k <sq; k ++)
{
If (I> k * k)
{
Int m = k;
For (; m <sq; m ++)
{
If (I> m * m)
{
If (I = (m * m + k * k ))
{
F ++;
}
}
}
}
}
If (f> 1)
{
R ++;
}
}
}
Return r;
}
}