... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Tuesday, December 31, 2013

UVA-11137 :: Ingenuous Cubrency

//Problem link >> http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2078

#include <bits/stdc++.h>
#define lli long long int
using namespace std ;

int main ()
{
     lli  i , j , coin[100] , n ,dp[10005] ,take ;
    for (i=1 ; i<=21 ; i++) coin[i]=i*i*i ;

   while(cin>>n)
   {
       memset(dp,0,sizeof (dp)) ;
       dp[0]=1 ;
       for (i=1 ; i<=21 ; i++)
       {
           take=coin[i] ;

          for (j=1 ; j<=n; j++)
          {
              if (j-take>=0) dp[j]=dp[j]+dp[j-take] ;
          }

       }
       cout<<dp[n]<<endl ;
   }

    return 0 ;
}

No comments:

Post a Comment