We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Project Euler #31: Coin sums
You are viewing a single comment's thread. Return to all 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.