project euler problem 452
long products
This problems looks very challenging, but actually it is not since the product is limited to 1e9 and 2^30 > 1e9. But to solve the PE problems, we cannot be too lazy. I first tried to use recursion to solve the problem without any optimization, for those two given numbers, 10 takes no time, but 1e6 takes a little bit of time, this is a bad symptom. I then tried 1e9, it is extremely slow. But after a moment's thought, I found that I was too lazy and some basic optimization was omitted. After one hour or so, the problem is solved. Not very difficult but need to keep optimization in mind!
No comments:
Post a Comment