Thursday, May 16, 2013

project euler problem 179

Consecutive positive divisors

Another simple problem, isn't it?

Yes, it is simple, but it is not so easy to get the answer in less than 0.3 second. I did not keep my old code, so I wrote one in five minutes. It takes 1.8 second to get the answer. 

Then I checked some of discussion,  I found I am too stupid that I missed an easy optimization. After that optimization, I can get the answer in 0.9 second. 

I then checked robert_gerbicz's code. Oh, my god, he got it in 0.4 second! When I went to page 3, I found another interesting solution. ftfish managed to solve it in 0.3 second!
His algorithm is very interesting! (although cost a little bit more memory the robert's solution).

I learned some useful stuff for some more difficult problems. 

No comments:

Post a Comment