11137-ingenuous cubrency
Time limit:3.000 seconds
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem= 2078
People in cubeland use cubic coins. Not only the "unit of" currency is called ACube but also the coins are-like shaped and cubes values their. Coins with values of "all" cubic numbers up to 9261 (= 213), i.e., coins with the denominations of 1, 8, ..., up to 9261 cubes, are available in Cubeland.
Your task is to count the number of ways to pay a given amount using cubic coins of cubeland. For example, there are 3 ways to pay one 1cube cubes:twenty, or one 8 cube coins and coin 1 cube thirteen, or TW o 8 cube coin and five 1 cube coins.
Input consists of lines each containing a integer amount to is paid. You may assume the amounts are positive and less than 10000.
For each of the given amounts to is paid output one line containing a single integer representing the number of ways to PA Y the given amount using the coins available in Cubeland.
Sample input
9999
Output for sample input
2
3
440022018293
This article URL address: http://www.bianceng.cn/Programming/sjjg/201410/45372.htm
can be converted into one dimension to do: Dp[i] + + + dp[i-a[j]];//continuously to a larger number of superimposed.
Complete code:
/*0.015s*/
#include <cstdio>
const int MAXN = 10000;
Long long DP[MAXN];
int a[22];
int main ()
{
int i, j, N;
for (i = 1; I <= ++i)
A[i] = i * i * i;
for (i = 0; I <= maxn ++i)
dp[i] = 1;
for (j = 2; J <=. ++j) for
(i = a[j]; I <= maxn; ++i)
dp[i] + = dp[i-a[j]];
while (~SCANF ("%d", &n))
printf ("%lld\n", Dp[n));
return 0;
}