# LeetCode Daily 12(LeetCode Daily 12)-ai

## LeetCode Daily 12(LeetCode Daily 12)

2022-1-15 T1716.计算力扣银行的钱

``````Hercy 想要为购买第一辆车存钱。他 每天 都往力扣银行里存钱。

``````输入：n = 20

``````class Solution {
public:
int totalMoney(int n) {
int res = 0;
for(int i = 0; i < n / 7; i++) {
res += (countSum(7) + 7 * i);
}
res += (countSum(n % 7) + (n / 7) * (n % 7));
return res;
}

int countSum(int n) {
int sum = 0;
for(int i = 1; i <= n; i++) {
sum += i;
}
return sum;
}
};``````
————————

2022-1-15 T1716. Calculate the power to deduct money from the bank < / strong >

< strong > Title Description: < / strong >

``````Hercy 想要为购买第一辆车存钱。他 每天 都往力扣银行里存钱。

< strong > example: < / strong >

``````输入：n = 20

< strong > ideas: < / strong >

< strong > first calculate the money deposited in the whole week (7 days), and then calculate the money deposited in the remaining days

< strong > code: < / strong >

``````class Solution {
public:
int totalMoney(int n) {
int res = 0;
for(int i = 0; i < n / 7; i++) {
res += (countSum(7) + 7 * i);
}
res += (countSum(n % 7) + (n / 7) * (n % 7));
return res;
}

int countSum(int n) {
int sum = 0;
for(int i = 1; i <= n; i++) {
sum += i;
}
return sum;
}
};``````