2240.cpp (242B)
1 class Solution { 2 public: 3 long long waysToBuyPensPencils(int total, int cost1, int cost2) const { 4 long long res = 0; 5 for (; total >= 0; total -= cost1) 6 res += 1ll + total / cost2; 7 return res; 8 } 9 };