其他分享
首页 > 其他分享> > 计算力扣银行的钱

计算力扣银行的钱

作者:互联网

题目

class Solution {
public:
    int totalMoney(int n) {
        int week,offset;
        int total=0;
        for(int i=0;i<n;i++){
              week=i/7;
              offset=i%7+1;
              total+=week+offset;
        }
        return total;
    }
};

这里计算偏移量从零开始,可以避免前一个轮回结束数字为0

标签:week,计算力,int,totalMoney,银行,offset,total
来源: https://blog.csdn.net/blue_all_by_xu/article/details/115406776