UVa 11137 - Ingenuous Cubrency

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

简单递推

代码:

#include <iostream>

#include <cstdio>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>



#define ll long long

using namespace std;



const int N=10005;

ll sum[N][50];

int main()

{

    //freopen("data.in","r",stdin);

    memset(sum,0,sizeof(sum));

    sum[0][1]=1;

    for(int i=1;i<N;++i)

    {

        for(int j=1;j*j*j<=i;++j)

        {

            for(int l=1;l<=j;++l)

            {

                sum[i][j]+=(sum[i-j*j*j][l]);

            }

            sum[i][0]+=sum[i][j];

        }

    }

    int k;

    while(cin>>k)

    {

        cout<<sum[k][0]<<endl;

    }

    return 0;

}

 

你可能感兴趣的:(uva)