Tap here to switch tabs
Problem
Submissions

Problem: Most Expensive Item That Can Not Be Bought

med
30 min
Try to solve the Most Expensive Item That Can Not Be Bought problem.

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

med
30 min
Try to solve the Most Expensive Item That Can Not Be Bought problem.

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