Project Euler #31: Coin sums

  • + 0 comments

    Initially, I didn't read "N is given as p and not £". I thought holy sh*t.

    I made my program so optimised that it precalc. values upto £10^5 = 10^7p in 232ms on my machine. Later, while submitting I found that it's p. lol

    Hint: Use memoization coinvalue-wise. And don't use Modulus opertor for adding. Check for overflow, if it overflow then subtract by modulus value. Modulus operator is costlier than branch followed by subtract.