当前位置:网站首页>Number of DP schemes
Number of DP schemes
2022-07-02 20:32:00 【. dye】
A man came to buy melons . “ cronies , How much is this melon per kilo ” “ Two yuan a catty ” “What's up, This melon skin is made of gold , Or melon particles are made of gold ”
Zhinai came to the fruit stall to buy melons , Fruit stands are selling N Different watermelons , The first i The weight of a watermelon is wi. Zhinai can choose to buy a whole melon or split the melon to buy half a melon for each melon , The weight of half a melon is wi/2.
That is to say, for every watermelon , Zhinai has three different decisions :
- Buy a whole weight of wi Watermelon of
- Split the melon , Buy half a weight of wi/2 Watermelon of
- Do not purchase
To simplify the topic , We guarantee that the weight of all melons is a positive even number .
Now zhinai wants to know , If he wants to buy watermelon, the weight and are k=1,2,3...M when , How many plans are there to buy watermelon , Because these figures may be very large , Please output the number of scheme pairs 10^9+7 The result after taking the remainder .
Input description :
Enter two integers on the first line N,M(0≤N≤10^3,1≤M≤10^3), Each represents the number of watermelons N, And the upper limit of the weight of the query is M.
if N Not for 0, Next line N A positive even number wi(2≤wi≤2×10^3) Represents the weight of each watermelon .
Output description :
Output one line M A digital , It means the weight of watermelon purchased and k=1,2,3...M when , How many plans are there to buy watermelon , Because these figures may be very large , Please output the number of scheme pairs 10^9+7 The result after taking the remainder .
Example 1
Input
Copy 3 6 8 2 4
3 6 8 2 4
Output
Copy 1 2 1 3 2 3
1 2 1 3 2 3
explain
The purchase weight and is 1 Watermelon in total 1 Kind of plan :
①、2 Split No. watermelon and buy half .
The purchase weight and is 2 Watermelon in total 2 Kind of plan :
①、 Direct purchase 2 Watermelon No .
②、3 Split No. watermelon and buy half .
The purchase weight and is 3 Watermelon in total 1 Kind of plan :
①、2 Split the No. 1 watermelon and buy half, plus 3 Split No. watermelon and buy half .
The purchase weight and is 4 Watermelon in total 3 Kind of plan :
①、1 Split No. watermelon and buy half .
②、 Direct purchase 2 Watermelon No , Plus 3 Split No. watermelon and buy half .
③、 Direct purchase 3 Watermelon No .
The purchase weight and is 5 Watermelon in total 2 Kind of plan :
①、2 Split watermelon No. 1 and buy half of it directly 3 Watermelon No .
②、2 Split the No. 1 watermelon and buy half, plus 1 Split No. watermelon and buy half .
The purchase weight and is 6 Watermelon in total 3 Kind of plan :
①、 Direct purchase 2 Watermelon No , Plus direct purchase 3 Watermelon No .
②、1 Split No. watermelon and buy half , Plus direct purchase 2 Watermelon No .
③、1 Split No. watermelon and buy half , Plus 3 Split No. watermelon and buy half .
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1010];
ll dp[1010];
ll n,m;
const ll M=1e9+7;
int main()
{
cin>>n>>m;
memset(dp,0,sizeof(dp));dp[0]=1;
for(ll i=1;i<=n;i++){cin>>a[i];}
for(ll i=1;i<=n;i++){
for(ll j=m;j>=1;j--){
if(j>=a[i])dp[j]=(dp[j]+dp[j-a[i]])%M;
if(j>=a[i]/2)dp[j]=(dp[j]+dp[j-a[i]/2])%M;
}
}
for(ll i=1;i<=m;i++)
cout<<dp[i]%M<<' ';
return 0;
}边栏推荐
- Outsourcing for three years, abandoned
- CheckListBox control usage summary
- SBT tutorial
- Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of the inverted front fork of the global market in 2022
- sql-labs
- Attack and defense world PWN question: Echo
- Sometimes only one line of statements are queried, and the execution is slow
- ROS learning (10): ROS records multiple topic scripts
- JDBC | Chapter 3: SQL precompile and anti injection crud operation
- Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of voltage source converters in the global market in 2022
猜你喜欢

Development skills of rxjs observable custom operator

Motivation! Big Liangshan boy a remporté le prix Zhibo! Un article de remerciement pour les internautes qui pleurent
In depth understanding of modern web browsers (I)

Basic concept of database, installation and configuration of database, basic use of MySQL, operation of database in the project

Implementing yolox from scratch: dataset class

Taiwan SSS Xinchuang sss1700 replaces cmmedia cm6533 24bit 96KHz USB audio codec chip

Why do I have a passion for process?

测试人员如何做不漏测?这7点就够了
[译]深入了解现代web浏览器(一)

B-end e-commerce - reverse order process
随机推荐
upload-labs
Attack and defense world PWN question: Echo
After 65 days of closure and control of the epidemic, my home office experience sharing | community essay solicitation
分享几个图床网址,便于大家分享图片
I want to ask you, where is a better place to open an account in Dongguan? Is it safe to open a mobile account?
Use graalvm native image to quickly expose jar code as a native shared library
【每日一题】241. 为运算表达式设计优先级
Automatic reading of simple books
AcWing 1135. Happy New Year (shortest path + search)
Friends who firmly believe that human memory is stored in macromolecular substances, please take a look
Highly qualified SQL writing: compare lines. Don't ask why. Asking is highly qualified..
什么叫在线开户?现在网上开户安全么?
【QT】QPushButton创建
Detailed explanation of VBScript (I)
Is it safe to open an account for online stock speculation? I'm a novice, please guide me
burp 安装 license key not recognized
Interested parties add me for private chat
[cloud native topic -50]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware MySQL microservice deployment process
c语言链表--待补充
I would like to ask what securities dealers recommend? Is it safe to open a mobile account?