Classic lookup Method
Static int [] arr;
Static T2 ()
{
Arr = new int [1593];
Arr [0] = 1729;
Arr [1] = 4104;
Arr [2] = 13832;
Arr [3] = 20683;
Arr [4] = 32832;
Arr [5] = 39312;
Arr [6] = 40033;
Arr [7] = 46683;
.........
Arr [1585] = 1156658048;
Arr [1586] = 1167270776;
Arr [1587] = 1181984832;
Arr [1588] = 1217741768;
Arr [1589] = 1228225789;
Arr [1590] = 1231216119;
Arr [1591] = 1234859661;
Arr [1592] = 1477354411;
}
Public static int count (int n)
{
Int max = 1592;
Int min = 0;
Int cur = 0;
While (max> = min)
{
Cur = (MAX + min)/2;
If (n <arr [cur])
{
Max = cur-1;
}
Else if (n> arr [cur])
{
Min = cur + 1;
}
Else
{
Break;
}
}
If (max <min)
{
Cur = max;
}
Return cur + 1;
}
Internally implement a binary search with an excessively large value returned when a failure occurs.
475574 of 10 queries took 10 ms
It is only for play, but it is actually the internal processing method of many mathematical libraries. I don't believe that math. Sin will perform actual operations.
Full code/files/Chinese-Xu/t2_chinesexutable.rar