Tap here to switch tabs
Problem
Submissions

Problem: Most Expensive Item That Can Not Be Bought

Most Expensive Item That Can Not Be Bought gives you two prime coin denominations with unlimited supply. Return the highest price that cannot be formed using nonnegative counts of either coin.

Statement

You are given two prime numbers primeOne and primeTwo.

There is an infinite supply of coins having denominations primeOne and primeTwo. An item with price xx can be bought if there exist non negative integers aa and bb such that a⋅a \cdot primeOne +b⋅+ b \cdot primeTwo =x= x.

Return the maximum price of an item that cannot be bought.

Constraints:

  • 1<1 < primeOne, primeTwo <104< 10^4

  • primeOne and primeTwo are prime numbers.

  • primeOne ⋅\cdot primeTwo <105< 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Most Expensive Item That Can Not Be Bought

Most Expensive Item That Can Not Be Bought gives you two prime coin denominations with unlimited supply. Return the highest price that cannot be formed using nonnegative counts of either coin.

Statement

You are given two prime numbers primeOne and primeTwo.

There is an infinite supply of coins having denominations primeOne and primeTwo. An item with price xx can be bought if there exist non negative integers aa and bb such that a⋅a \cdot primeOne +b⋅+ b \cdot primeTwo =x= x.

Return the maximum price of an item that cannot be bought.

Constraints:

  • 1<1 < primeOne, primeTwo <104< 10^4

  • primeOne and primeTwo are prime numbers.

  • primeOne ⋅\cdot primeTwo <105< 10^5