当前位置:网站首页>278. digital combination
278. digital combination
2022-06-23 01:37:00 【Jiang Tianyi color】
Given N A positive integer A1,A2,…,ANA1,A2,…,AN, Choose a number from them , Make their sum for M, Find out how many options there are .
Input format
The first line contains two integers N and M.
The second line contains N It's an integer , Express A1,A2,…,AN.
Output format
Contains an integer , Indicates the number of options .
Data range
1≤N≤100,
1≤M≤10000,
1≤Ai≤1000,
The answer is guaranteed in int Within the scope of .
sample input :
4 4
1 1 2 2
sample output :
3
This problem is actually to use the total number of schemes = choice a[i] Number of alternatives + No choice a[i] The total number of schemes added up
#include<iostream>
using namespace std;
int main()
{
int n,m;
int a[110],f[10010];//f[i] Express and for i Number of alternatives
cin>>n>>m;
f[0]=1;// And for 0 It's like choosing none , There is only one case
for(int i=0;i<n;i++)
{
cin>>a[i];
for(int j=m;j>=a[i];j--)
f[j]+=f[j-a[i]];// And for j The total number of programs = Choose the first i The number of schemes + No second choice i The number of schemes
}
cout<<f[m]<<endl;
return 0;
}边栏推荐
- C# SerializableDictionary序列化/反序列化
- Read Amazon memorydb database based on redis
- a++,++a,!,~
- [launch] redis Series 2: data persistence to improve availability
- Get the direction of mouse movement
- Flink synchronizes MySQL data to es
- leetcode 91. Decode ways (medium)
- C#. Net universal database access encapsulation classes (access, sqlserver, Oracle)
- [UVM] don't say that your VIP can't use ral model
- Time complexity
猜你喜欢
![[sliding window] leetcode992 Subarrays with K Different Integers](/img/69/1ac0c54d33af0f7a9e3db3e82d076b.png)
[sliding window] leetcode992 Subarrays with K Different Integers

Debian10 LVM logical volumes

Ros2 summer school 2022 transfer-

Use elk to save syslog, NetFlow logs and audit network interface traffic

MySQL-Seconds_ behind_ Master accuracy error
![[initial launch] there are too many requests at once, and the database is in danger](/img/c1/807575e1340b8f8fe54197720ef575.png)
[initial launch] there are too many requests at once, and the database is in danger

SFOD:无源域适配升级优化,让检测模型更容易适应新数据

SAP mm transaction code vl04 create outbound delivery for sto
![[learning notes] roll back Mo team](/img/19/d374dd172b9609a3f57de50791b19e.png)
[learning notes] roll back Mo team

Steps to implement a container global component
随机推荐
Centos7 installing postgresql12
Using WordPress to create a MySQL based education website (learning notes 2) (technical notes 1) xampp error1045 solution
Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe
Use of higher order functions
3DMAX modeling notes (I): introducing 3DMAX and creating the first model Hello World
SQL programming task05 job -sql advanced processing
Read Amazon memorydb database based on redis
Js--- SVG to png
New progress in the construction of meituan's Flink based real-time data warehouse platform
[launch] redis Series 2: data persistence to improve availability
[hdu] p7058 ink on paper finding the maximum edge of the minimum spanning tree
Dual cross domain: access allow origin header contains multiple values "*, *", but only one is allowed
Pat a - 1010 radical (thinking + two points)
[learning notes] roll back Mo team
Extend your kubernetes API using the aggregation API
Lexical Sign Sequence
MySQL-Seconds_ behind_ Master accuracy error
Unit of RMB in words
Project directory navigation
Zabbix5 series - use temperature and humidity sensor to monitor the temperature and humidity of the machine room (XX)