1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/采购方案 [4xy4Wx].md
2022-03-29 12:43:11 +08:00

27 lines
746 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

小力将 N 个零件的报价存于数组 `nums`。小力预算为 `target`,假定小力仅购买两个零件,要求购买零件的花费不超过预算,请问他有多少种采购方案。
注意:答案需要以 `1e9 + 7 (1000000007)` 为底取模,如:计算初始结果为:`1000000008`,请返回 `1`
**示例 1**
>输入:`nums = [2,5,3,5], target = 6`
>
>输出:`1`
>
>解释:预算内仅能购买 nums[0] 与 nums[2]。
**示例 2**
>输入:`nums = [2,2,1,9], target = 10`
>
>输出:`4`
>
>解释:符合预算的采购方案如下:
>nums[0] + nums[1] = 4
>nums[0] + nums[2] = 3
>nums[1] + nums[2] = 3
>nums[2] + nums[3] = 10
**提示:**
- `2 <= nums.length <= 10^5`
- `1 <= nums[i], target <= 10^5`