class Solution {
public:
int totalMoney(int n) {
vector<int> m(8, 0);
for (int i = 1; i < 8; i++)
{
m[i] = i;
}
int money = 0;
int index = 1;
for (int i = 0; i < n; i++)
{
money += m[index++];
if (index == 8)
{
index = 1;
for (int j = 1; j < 8; j++)
{
m[j] += 1;
}
}
}
return money;
}
};
LeetCode 计算力扣银行的钱
猜你喜欢
转载自blog.csdn.net/qq_32862515/article/details/113356855
今日推荐
周排行