Coin 1
#include <bits/stdc++.h> #define M 10000 using namespace std; int n,k,A[M+5],dp[M+5]; void input(){ cin>>n>>k; for(int i=0;i<n;i++){ cin>>A[i]; } } void DP(){ dp[0]=1; for(int i=0;i<n;i++){ for(int j=1;j<=k;j++){ if(j>=A[i])dp[j]+=dp[j-A[i]]; } } } int main(){ cin.tie(0); ios::sync_with_stdio(false); //freopen("in.txt","r",stdin); input(); DP(); cout<<dp[k]<<endl; return 0; }

Comments
Post a Comment