当前位置:网站首页>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;
}
边栏推荐
- 【CVPR2022】QueryDet论文精读
- (completely solved) dataframe assignment settingwithcopywarning: a value is trying to be set on a copy of a slice
- go for it Easily manage all types of items with "flying items"
- torch. Var (), sample variance, parent variance
- ICML2022有意思的文章
- Web design and website planning assignment 13 making video playlists
- Classical graph theory, depth first and breadth first, topology, prim and krukal, it's time to review
- centos随笔03:centos8.2安装mysql
- AttributeError: module ‘tensorflow. compat. v2.__ internal__‘ has no attribute ‘register_ clear_ session_
- Oracle learning (I)
猜你喜欢

结果和目标出入太大?不妨借助目标管理精准直达目标!

These gadgets are also very easy to use

torch. meshgrid

Study the Analects of entanglement

(resolved) typeerror: meshgrid() got an unexpected keyword argument 'indexing‘

【CVPR2022】QueryDet论文精读

(taking pytorch as an example) a simple understanding of the regularization method of path (depth) -drop path

经典图论,深度优先和广度优先,拓扑,Prim和Krukal,该来温习啦

进程间的通信
![[software tools] screen recording software captura](/img/79/705bb40fc15322243880f3b9864f2b.jpg)
[software tools] screen recording software captura
随机推荐
Typescript keyboard mapping
Use guidelines in constraintlayout to limit the maximum width of controls
Node error report sorting
使用POSTMAN 测试firebase
Several ways to avoid concurrent modification exceptions of lists
盘它!用「飞项」轻松管理各类型项目
【1】 Integrated learning: quickly understand Integrated Learning
B+ super tree helps you know the underlying structure of MySQL
Process control: process waiting (recycling child processes)
[software tool] installation ffmpeg
SSM file upload and download
Typescript recognizable Union
Implementation of CRF for named entity recognition
Installing MySQL and cluster operation on virtual machine in Linux system
qiao-lerna:lerna辅助工具
Typescript null and undefined
How to do a good job in project management? Learning these four steps is enough
bat 批处理单独环境打包
Introduction to guava cache usage
Planning tasks for continuous automated testing