/*
* @lc app=leetcode.cn id=1716 lang=typescript
*
* [1716] 计算力扣银行的钱
*/
// @lc code=start
function totalMoney(n: number): number {}
// @lc code=end
function totalMoney(n: number): number {
const dp: number[] = [0, 0, 1, 3, 6, 10, 15, 21]
let week = Math.floor(n / 7)
return ((week * (week + 1)) / 2) * 7 + week * 21 + (week + 1) * (n % 7) + dp[n % 7]
}
test.each([
{ input: { n: 4 }, output: 10 },
{ input: { n: 7 }, output: 28 },
{ input: { n: 8 }, output: 30 },
{ input: { n: 9 }, output: 33 },
{ input: { n: 10 }, output: 37 },
{ input: { n: 20 }, output: 96 },
])('input: n = $input.n', ({ input: { n }, output }) => {
expect(totalMoney(n)).toEqual(output)
})