Advertisement
happy_nesquik

Untitled

Sep 28th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define _ ios_base::sync_with_stdio(0);cin.tie(0);
  6. int n2, n5, n10, n20, n50, n100;
  7. int v[6];
  8.  
  9. int pd[5005][7][505];
  10. int resp(int n, int mini, int usei){
  11.     if(pd[n][mini][usei]!=-1) return pd[n][mini][usei];
  12.     if(n==0){
  13.         return pd[n][mini][usei]=1;
  14.     }
  15.     int tot = 0;
  16.     if(n-100>=0 and mini>5 and v[5]!=0) tot+= resp(n-100, 5, 1);
  17.     else if(n-100>=0 and mini==5 and usei<v[5]) tot+= resp(n-100, 5, usei+1);
  18.  
  19.     if(n-50>=0 and mini>4 and v[4]!=0) tot+= resp(n-50, 4, 1);
  20.     else if(n-50>=0 and mini==4 and usei<v[4]) tot+= resp(n-50, 4, usei+1);
  21.  
  22.     if(n-20>=0 and mini>3 and v[3]!=0) tot+= resp(n-20, 3, 1);
  23.     else if(n-20>=0 and mini==3 and usei<v[3]) tot+= resp(n-20, 3, usei+1);
  24.  
  25.     if(n-10>=0 and mini>2 and v[2]!=0) tot+= resp(n-10, 2, 1);
  26.     else if(n-10>=0 and mini==2 and usei<v[2]) tot+= resp(n-10, 2, usei+1);
  27.  
  28.     if(n-5>=0 and mini>1 and v[1]!=0) tot+= resp(n-5, 1, 1);
  29.     else if(n-5>=0 and mini==1 and usei<v[1]) tot+= resp(n-5, 1, usei+1);
  30.  
  31.     if(n-2>=0 and mini>0 and v[0]!=0) tot+= resp(n-2, 0, 1);
  32.     else if(n-2>=0 and mini==0 and usei<v[0]) tot+= resp(n-2, 0, usei+1);
  33.  
  34.     return pd[n][mini][usei] = tot;
  35. }
  36. int main(){ _
  37.     memset(pd, -1, sizeof(pd));
  38.     int n;
  39.     cin >> n;
  40.     cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5];
  41.     int tot = 0;
  42.     if(n>=100 and v[5]!=0) tot+= resp(n-100, 5, 1);
  43.     if(n>=50 and v[4]!=0) tot+= resp(n-50, 4, 1);
  44.  
  45.     if(n>=20 and v[3]!=0) tot+= resp(n-20, 3, 1);
  46.     if(n>=10 and v[2]!=0) tot+= resp(n-10, 2, 1);
  47.     if(n>=5 and v[1]!=0) tot+= resp(n-5, 1, 1);
  48.      if(n>=2 and v[0]!=0) tot+= resp(n-2, 0, 1);
  49.     cout << tot << endl;
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement