UVa 147 dollars: Classic dp& coin combination number & integer split

Source: Internet
Author: User

147-dollars

Time limit:3.000 seconds

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

and UVA 3,571-like.

Notice that all the numbers are divided by 5.

Complete code:

/*0.019s*/
    
#include <cstdio>  
#include <cstring>  
const int COIN[11] = {1, 2, 4, 10, 20, 40, 100, 200 , 1000, the same;  
const int MAXN = 6001;  
    
Long long DP[MAXN];  
    
int main ()  
{  
    int i, K, N, a, B;  
    Dp[0] = 1;  
    for (k = 0; k < a ++k)  
        for (i = coin[k]; i < MAXN; ++i)///Note the order of state transitions  
            dp[i] + = dp[i-coin[k]];  
    while (scanf ("%d.%d", &a, &b), a| | b)  
    {  
        n = (* a + B)/5;  
        printf ("%3d.%0 2d%17lld\n ", A, B, Dp[n]);  
    }  
    return 0;  
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

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.