1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-14 01:49:41 +01:00
LeetCode/cpp/calculate-money-in-leetcode-bank.cpp
Matej Focko b229608723
cpp(chore): add clang-format style and format
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-01-03 12:06:54 +01:00

15 lines
293 B
C++

class Solution {
public:
int totalMoney(int n) {
auto monday = 1;
int total = 0;
for (; n >= 7; ++monday, n -= 7) {
total += 7 * (2 * monday + 7 - 1) / 2;
}
total += n * (monday + monday + n - 1) / 2;
return total;
}
};