Skip to content

Commit 3d9f199

Browse files
authoredJan 15, 2023
Create Number of Ways to Buy Pens and Pencils
1 parent 8b91f4c commit 3d9f199

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
long long waysToBuyPensPencils(int total, int cost1, int cost2) {
4+
long long cnt=0;
5+
for(long long i=0;i<=total/cost1;i++){
6+
if(total>=cost1*i){
7+
cnt=cnt+(total-cost1*i)/cost2+1;
8+
}
9+
10+
}
11+
return cnt;
12+
}
13+
};

0 commit comments

Comments
 (0)
Please sign in to comment.