Advertisement
shamiul93

Ingenuous Cubrency UVA - 11137

Mar 9th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. /**
  2. @author - Rumman BUET CSE'15
  3. problem -  Ingenuous Cubrency UVA - 11137
  4.  
  5. */
  6. #include<bits/stdc++.h>
  7. #define ll long long
  8. #define fo freopen("out.txt","w",stdout)
  9. #define fi freopen("in.txt","r",stdin)
  10. #define DEBUG printf("hi\n");
  11. #define DEBUG2 printf("bi\n");
  12. #define pi acos(-1)
  13. #define cube(a) a*a*a
  14. //#define m 100000007
  15. #define d 0.000000001
  16.  
  17. using namespace std ;
  18.  
  19. ll curr[100];
  20. ll dp[25][2000000] ;
  21.  
  22.  
  23. ll rec(ll i , ll n)
  24. {
  25.     if(n == 0)
  26.     {
  27.         return 1 ;
  28.     }
  29.     if(n < 0)
  30.         return 0 ;
  31.     if(i >= 21 && n > 0)
  32.     {
  33.         return 0 ;
  34.     }
  35.  
  36.     if(dp[i][n]!=-1)
  37.     {
  38.         return dp[i][n] ;
  39.     }
  40.  
  41.     return dp[i][n] = rec(i , n - curr[i]) + rec(i+1 , n) ;
  42. }
  43.  
  44.  
  45. int main()
  46. {
  47.     for(ll i = 1 ; i <= 21 ; i++)
  48.     {
  49.         curr[i-1] = cube(i)  ;
  50.     }
  51.  
  52.     ll a ;
  53.     memset(dp , -1 , sizeof(dp)) ;
  54.  
  55.     while(scanf("%lld",&a)!= EOF)
  56.     {
  57.         ll ans ;
  58.         ans = rec(0 , a) ;
  59.         printf("%lld\n" , ans) ;
  60.     }
  61.  
  62.     return 0 ;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement