Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of profit Planning by golang leetcode dynamic Planning

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the golang brush leetcode dynamic planning how to solve the problem of profit planning, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

There are G members in the gang who may commit all kinds of crimes.

The type I crime generates profits from profit [I], which requires the participation of group [I] members.

Let's call any subset of these crimes a profit plan, which generates at least P profits.

How many options are available? Because the answer is large, it returns a value of 10 ^ 9 + 7.

Example 1:

Input: G = 5, P = 3, group = [2jue 2], profit = [2pr 3]

Output: 2

Explanation:

Generate at least 3% of the profit, the gang can commit crime 0 and crime 1, or only crime 1.

In general, there are two options.

Example 2:

Input: G = 10, P = 5, group = [2Jing 3JEI 5], profit = [6Jing 7JI 8]

Output: 7

Explanation:

Generate at least 5% profit, as long as they commit one of these crimes, so the gang can commit any crime.

There are seven possible plans: (0), (1), (2), (0meme1), (0meme2), (1meme2), and (0meme1mem2).

Tip:

one

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report