Monday, April 15, 2013

project euler problem 111

Primes with runs

From problem 110, the answer became large, so nobody can guess. And this also force us to think about some clever ways to solve the problem. 

I checked my old code, it is not too bad, so I decided not to rewrite it. To solve problem like this one,  I learned how to find the next combination number, something like next_permutation in STL. If one does not want to do it this way, the easiest way is probably recursion.

It takes 24ms to get the answer,  not bad.


No comments:

Post a Comment