Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Buy Pens and Pencils

Number of Ways to Buy Pens and Pencils asks you to count distinct combinations of pens and pencils, using their prices to stay within a given budget and allowing none.

Statement

You are given an integer total representing an amount of money, and two integers cost1 and cost2 representing the price of a pen and a pencil, respectively.

Return the number of distinct ways to purchase some number of pens and pencils such that the total cost spent does not exceed total. You may purchase 00 pens and 00 pencils.

Constraints:

  • 1≤1 \leq total, cost1, cost2 ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Buy Pens and Pencils

Number of Ways to Buy Pens and Pencils asks you to count distinct combinations of pens and pencils, using their prices to stay within a given budget and allowing none.

Statement

You are given an integer total representing an amount of money, and two integers cost1 and cost2 representing the price of a pen and a pencil, respectively.

Return the number of distinct ways to purchase some number of pens and pencils such that the total cost spent does not exceed total. You may purchase 00 pens and 00 pencils.

Constraints:

  • 1≤1 \leq total, cost1, cost2 ≤106\leq 10^6