UVa 11137 ingenuous cubrency (DP)

Source: Internet
Author: User

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;  
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.