当前位置:网站首页>leetcode - 518. Change II
leetcode - 518. Change II
2022-06-11 08:43:00 【zmm_ mohua】
leetcode - 518. Change for II
subject

Code
#include <iostream>
#include <vector>
using namespace std;
int change(int amount, vector<int>& coins) {
vector<int> dp(amount+1);
dp[0] = 1; // The amount of money is 0 when , Means you don't take any change , So it is 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;
}
边栏推荐
- 补2:圆环回原点问题
- js 中 Map 和 Set 的用法及区别
- Can not connect to local MySQL server through socket ‘/tmp/mysql. sock (2)‘
- (the slow download speed of cifar10 in torchvision has been solved) how to download and use torchvision import
- How to do a good job in project management? Learning these four steps is enough
- leetcode - 739. 每日温度
- Swagger study notes
- 你所不知道的console
- MySQL upgrade
- Cron expressions in scheduled tasks
猜你喜欢

Using flying items to manage by objectives, not being a "headless fly" in the workplace

这几个小工具也太好用了

深度学习入门之pytorch安装

What is concurrent search set? Are you still worried about it? In fact, it is a problem of connected graph, which is not so difficult to understand

Introduction to guava cache usage

ActiveMQ简单教程,适合初学者,学习笔记yyds

How to do a good job in project management? Learning these four steps is enough

torch. roll

用飞项进行目标管理,不做职场上的“无头苍蝇”

leetcode - 518. 零钱兑换 II
随机推荐
Bat batch processing separate environment packaging
【CVPR2022】QueryDet论文精读
leetcode - 460. LFU 缓存
Redis6 entry-level tutorial. There are integration cases. You can directly see the integration cases. It is easy to get started
leetcode - 518. 零钱兑换 II
Planning tasks for continuous automated testing
torch. unbind()
Cron expressions in scheduled tasks
Disk format FAT32, exFAT, NTFS of [software tool]
GCC AVR(Atmel Studio+ AVR Studio)如何将结构体数组定义在程序存储器(flash)空间并进行读操作
Solve notimplementederror: layer XX has arguments in`__ init__` and therefore must override `get_ config`
Redis cluster in Linux system
Introduction to knowledge atlas -- yedda annotation
用飞项进行目标管理,不做职场上的“无头苍蝇”
Pycharm启动卡死,loading project
ICML2022有意思的文章
剑指 Offer 40. 最小的k个数
二、渲染 Camera 的数据
How to do well in empty state design? Look at this comprehensive summary
mysql高级特性篇,可以多看看,应付面试