I have a slight improvement O ( n^2 log (n )  )

Say you have a^2 + b^2 + c^2 = d.

Keep a sorted list of all possible a^2 + b ^ 2 ... this would take n^2 time to generate and n^2 log n to sort. Now loop over all possible 'd' and 'c' and compute  d - c ^ 2. Use binary search to  determine whether that number is in the list ... if it is then 'd' is a number which CAN be represented otherwise try for the next 'c'.

There might be a better solution ... still thinking

-Dhyanesh

On 10/31/06, Karthik Rathinavelu < [EMAIL PROTECTED]> wrote:
Question: Given n, find the numbers in the range of 0...n which CAN'T be represented in the form of sum of squares of 3 non-negative numbers.

If anyone could possibly give a solution better than O(n^3), it will be good.

Thanks,
R.Karthik




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups-beta.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to