当前位置:网站首页>Class notes (4) (1) -571 Monetary system
Class notes (4) (1) -571 Monetary system
2022-07-20 13:10:00 【xyc20120615】
Description
To give you one n A monetary system of denominations , Find the face value of the composition as m How many currencies are there .
Format
Input
The first 1 Line two integers n and m (1<n≤1000,1<m≤10,000);
next n That's ok , One integer per row , Represents the amount of each face value ;
Output
The number of output schemes .
Samples
input data 1
3 10
1
2
5
Output data 1
10
Limitation
1s, 1024KiB for each test case.
Answer key :
Have to say , It's really double H2O 了
Loop through each face value , Then from the face value to the required amount, add , State transition equation :
dp[j]=dp[j]+dp[j-a[i]];// State transition equation
Program :
#include <bits/stdc++.h>
using namespace std;
long long dp[10010];// Number of schemes
int n,m,a[1010];
int main(){
dp[0]=1;
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++)// Traverse n Denomination
for(int j=a[i];j<=m;j++)
dp[j]=dp[j]+dp[j-a[i]];// State transition equation
cout<<dp[m];
return 0;
}
边栏推荐
猜你喜欢
Degradation technology of template and generic programming
Find - b+ tree
牛津大学:许多常见失眠药物缺乏长期安全数据
Write "Hello, china." for domestic smart watches with C #
Nacos配置管理——统一配置管理
Isn't it too much to play Gobang in idea?
scratch判断闰年 电子学会图形化编程scratch等级考试四级真题和答案解析2022年6月
A large number of programmers were discouraged!
QIODevice
零编码制作报表真地可能吗?
随机推荐
A go interview question about defer understanding
[Mamba] is CONDA slow?
A large number of programmers were discouraged!
C explanation of message dialog box based on MessageBox class
[deep learning] pytorch uses tensorboard to visualize experimental data
1305_ Basic queue function description of FreeRTOS
Docker安装常用软件-Redis
JS method of obtaining URL address bar parameters to solve the problem of Chinese garbled code
Sending the email to the following server failed. IOException while sending message problem solving
【数据集制作】标注工具
Mysql 主从配置
【数据库】概念设计、逻辑设计、关系数据库设计理论
2022-07-18:以下go语言代码输出什么?A:Groutine;B:Main;C:Goroutine;D:GoroutineMain。 package m
kmeans手写实现与sklearn接口
C# 基于MessageBox类的消息对话框讲解
Unity practical problems webgl problem collection part 2
PyG教程(8):计算更高效的稀疏矩阵形式
Several small open source projects of mine over the years
【JS】this指向的问题
Notepad++软件安装教程