Saleh127

CSES 1635

Apr 22nd, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll dp[1000005];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);cout.tie(0);
  10.  
  11.  
  12. ll n,m,i,j,k,l=1e9+7;
  13.  
  14. cin>>n>>m;
  15.  
  16. ll a[n+5];
  17.  
  18. for(i=0;i<n;i++)
  19. {
  20. cin>>a[i];
  21. }
  22.  
  23. dp[0]=1;
  24. for(i=1;i<=m;i++)
  25. {
  26. dp[i]=0;
  27.  
  28. for(j=0;j<n;j++)
  29. {
  30. if(i>=a[j] && dp[i-a[j]])
  31. {
  32. dp[i]+=dp[i-a[j]];
  33. }
  34.  
  35. }
  36. dp[i]%=l;
  37. }
  38.  
  39. cout<<dp[m]<<endl;
  40.  
  41.  
  42. return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment