3273. Most Expensive Item That Can Not Be Bought

Medium
Math
Dynamic Programming
Number Theory

Description

Hints

Hint 1
Write out a few cases. It can be seen that all items greater than <code>primeOne * primeTwo</code> can always be bought.
Hint 2
If we can buy items with cost <code>i</code>, we can also buy items with price <code>i + primeOne</code> and <code>i + primeTwo</code>.
Hint 3
Use dynamic programming.
Hint 4
There is an O(1) solution: Use the Chicken McNugget Theorem.

Statistics

Acceptance
80.3%
Submissions
7,870
Accepted
6,319