Find the Minimum Possible Sum of a Beautiful Array
You are given positive integers n and target.
An array nums is beautiful if it meets the following conditions:
nums.length == n.numsconsists of pairwise distinct positive integers.- There does not exist two distinct indices,
iandj, in the range[0, n - 1], such thatnums[i] + nums[j] == target.
Return the minimum possible sum that a beautiful array could have modulo 10^9 + 7.
Example 1
Input
n = 2, target = 3Output
4The array
nums = [1, 3] is beautiful, and it can be proven that 4 is the minimum possible sum.Example 2
Input
n = 3, target = 3Output
8The array
nums = [1, 3, 4] is beautiful, and it can be proven that 8 is the minimum possible sum.Constraints
- 1 <= n <= 10^9
- 1 <= target <= 10^9