当前位置:网站首页>leetcode - 518. 零钱兑换 II
leetcode - 518. 零钱兑换 II
2022-06-11 08:28:00 【zmm_mohua】
leetcode - 518. 零钱兑换 II
题目

代码
#include <iostream>
#include <vector>
using namespace std;
int change(int amount, vector<int>& coins) {
vector<int> dp(amount+1);
dp[0] = 1; // 钱数为0时,表示任何零钱也不拿,所以是1
for(int i = 0; i < coins.size(); i++){
int coin = coins[i];
for(int j = coin; j <= amount; j++){
dp[j] += dp[j-coin];
}
}
return dp[amount];
}
int main(){
int n, amount, res;
cin>>n>>amount;
vector<int> coins(n);
for(int i = 0; i < n; i++){
cin>>coins[i];
}
res = change(amount, coins);
cout<<res;
return 0;
}
边栏推荐
- Idea pulls items from remote warehouse
- Use of Excel to XML tool of TestLink
- Introduction to guava cache usage
- [programming development] markdown notes tutorial
- Interprocess communication
- The difference between equals and = =
- Solve cannot import name 'multiheadattention' from 'tensorflow keras. layers‘
- Typescript keyboard mapping
- 用飞项进行目标管理,不做职场上的“无头苍蝇”
- Js学习基础document.write在页面中写一行文字
猜你喜欢

Introduction to knowledge atlas -- yedda annotation

Zipkin入门

Study the Analects of entanglement

Introduction to database system experiment report answer Experiment 6: advanced query of data table

Oracle learning (I)

Web design and website planning assignment 12 online registration form

(resolved) the tqdm progress bar in the Jupiter notebook does not update and display in one line, but scrolls down to output

Deep understanding of add in argparse module_ Argument parameters (such as action)

Asynchronous notification mechanism of character device driver

Solve valueerror: no model found in config file
随机推荐
Idea annotation settings
torch. Var (), sample variance, parent variance
Dameng database login
Deep understanding of add in argparse module_ Argument parameters (such as action)
Testing firebase with postman
Oracle learning (I)
B+ super tree helps you know the underlying structure of MySQL
torch. unbind()
Use Jackson's @jsonproperty annotation to add one more field to the property name. Solution to the problem
Js学习基础document.write在页面中写一行文字
bat 批处理单独环境打包
Solve notimplementederror: layer XX has arguments in`__ init__` and therefore must override `get_ config`
Mongodb--- automatically delete expired data using TTL index
Introduction to knowledge atlas -- yedda annotation
命名实体识别之CRF的实现方式
Project training - clonemon
Swagger study notes
Disk format FAT32, exFAT, NTFS of [software tool]
Introduction to guava cache usage
Polymorphic interview questions