mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-13 02:38:37 +08:00
init
This commit is contained in:
21
23/09/Q2240.h
Normal file
21
23/09/Q2240.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Created by 李洋 on 2023/9/1.
|
||||
//
|
||||
|
||||
#ifndef LEECODE_C_2240_H
|
||||
#define LEECODE_C_2240_H
|
||||
|
||||
class Q2240 {
|
||||
public:
|
||||
long long waysToBuyPensPencils(int total, int cost1, int cost2) {
|
||||
long long count = total / cost2 + 1;
|
||||
int tos = total / cost1;
|
||||
for (int i = 1; i <= tos; ++i) {
|
||||
int temp = total - i * cost1;
|
||||
count += temp / cost2 + 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //LEECODE_C_2240_H
|
||||
Reference in New Issue
Block a user