Cover image for leetcode每日一题 P1716 计算力扣银行的钱

leetcode每日一题 P1716 计算力扣银行的钱


时间轴

时间轴

2025-10-26

init

数学

题目:

非常简单的数学题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct Solution;

impl Solution {
pub fn total_money(n: i32) -> i32 {
let week = n / 7;
let day = n % 7;

// 1,2 (1+2)*2/2

28 * week + 7 * (week - 1) * week / 2 + (week + 1 + week + day) * day / 2
}
}

fn main() {
println!("Hello, world!");
}