UVA 11137 Ingenuous Cubrency

题目大意:同uva 674,  硬币金额预处理。

解题策略:同uva 674。


/*
   UVA 11137 Ingenuous Cubrency
   AC by J.Dark
   ON 2013/3/25
   Time 0.008s
*/
#include 
#include 
#include 
using namespace std;
typedef unsigned long long int ULL;  //防止溢出,所以数据全是ull 
ULL coin[22], dp[10005];
ULL ans, N;

void preSolve(){
     for(int i=1; i<=21; i++)
        coin[i] = i*i*i;
     memset(dp, 0, sizeof(dp));
     dp[0] = 1;
     for(int coinNum=1; coinNum<=21; coinNum++){
        for(int money=1; money<=10005; money++){
           if(money >= coin[coinNum]) dp[money] += dp[money-coin[coinNum]]; 
        }
     }
}
////////////////////////////////////
int main(){
    preSolve();
    while(scanf("%ull", &N)!=EOF)
    {
       cout << dp[N] << endl;
    }
    //system("pause");
    return 0;
}


你可能感兴趣的:(Uva题解)