Saturday, May 4, 2013

project euler problem 153

Investigating Gaussian Integers

I checked my old code. It works, but the performance is poor, need 25 second to get the answer. I thought about it and then I found a very convenient formula for the problem when I was working on those real divisors. So I rewrote the code, and found the   performance is greatly improved. It was reduced to 3 second.

Then I read the discussion thread, Eigenray gave a very useful expression which can further improve the performance(it is not so difficult to prove). I tried it, the run time is reduced to 1.5 second. 

A great problem!

No comments:

Post a Comment