Product-sum numbers
First, we can find an upper bound for the minimal product-sum numbers. The rest of the job is just to find the minimal by checking all combinations. Brute force is still quite fast.Update 10/06/2017
Brute force method is usually not a good choice. I checked my old code and find it very inefficient. I used a top down method, which start from a number n and try to figure out all possible combinations that leads to a product of n. The worst thing is that I do not know the limit that I should pick. So in my old code I pick 1e7 and get the correct answer. After some thought, I figured out that a bottom up approach is better which can handle the limit much easier!
I think I learned a little bit from this review.
No comments:
Post a Comment