十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

leetcode 耗时100 1716. Calculate Money in Leetcode Bank

leetcode 耗时100 1716. Calculate Money in Leetcode Bank Problem: 1716. 计算力扣银行的钱等比数列求和的2828 7, 28 7 * 2最后累加上余数耗时100Codeclass Solution { public: int totalMoney(int n) { int id n / 7; int sum (28 28 max(0, (id - 1)*7)) * id / 2; int now 1 id; for(int i id * 7; i n; i ) { sum (now); } return sum; } };
返回列表