2024-03-08发表2025-01-15更新LeetCode每日一题几秒读完 (大约99个字)0次访问2834. 找出美丽数组的最小和找出美丽数组的最小和 难度: medium 原始链接: https://leetcode.cn/problems/find-the-minimum-possible-sum-of-a-beautiful-array 标签: 数学 解法一: 数学go12345678910111213const MOD = 1000000007func minimumPossibleSum(n int, target int) int { // 左边部分 left1 := 1 right1 := min(target>>1, n) leftSum := ((left1 + right1) * (right1 - left1 + 1)) >> 1 // 右边部分 left2 := target right2 := target + (n - (right1 - left1 + 1)) - 1 rightSum := ((left2 + right2) * (right2 - left2 + 1)) >> 1 return (leftSum + rightSum) % MOD} 2834. 找出美丽数组的最小和https://wuhunyu.top/leetcode/2024/03/find-the-minimum-possible-sum-of-a-beautiful-array/index.html作者wuhunyu发布于2024-03-08更新于2025-01-15许可协议#数学