Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <iostream>
- using namespace std;
- int main(){
- int moedas[] ={1, 5, 10, 25, 50};
- int n;
- cin>>n;
- int matriz[5][n+1];
- for(int i = 0; i<=n;i++){
- matriz[1][i] = 1;
- }
- for(int i = 0; i<=5;i++){
- matriz[i][1] = 1;
- }
- for(int i = 2; i<=5;i++){
- for(int j = 0; j<=n;j++){
- if(moedas[i]>j){
- matriz[i][j] = matriz[i-1][j];
- }else{
- matriz[i][j] = matriz[i-1][j]+matriz[i][j-moedas[i]];
- }
- }
- }
- cout<<matriz[5][n];
- }
Advertisement
Add Comment
Please, Sign In to add comment