2240. Number of Ways to Buy Pens and Pencils

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2240

class Solution:
    def waysToBuyPensPencils(self, total: int, cost1: int, cost2: int) -> int:
        res = 0
        for x in range(total // cost1 + 1):
            y = (total - (x * cost1)) // cost2 + 1
            res += y
        return res