백준 6126 c++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void input_coin(vector<int>& coin, int *N)
{
int V;
int i, temp;
cin >> V >> *N;
for (i = 0; i < V; i++)
{
cin >> temp;
coin.push_back(temp);
}
return;
}
void find_answer(vector<int> coin, int N)
{
long long total = 0;
int i;
vector<long long> coin_dp(N + 1, 0);
coin_dp[0] = 1;
for (int coin_unit : coin)
{
for (i = coin_unit; i <= N; i++)
{
coin_dp[i] += coin_dp[i - coin_unit];
}
}
cout << coin_dp[N];
return;
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N;
vector <int> coin;
input_coin(coin, &N);
find_answer(coin, N);
return 0;
}