Hdu 1284 Coin Exchange __hdu

Source: Internet
Author: User
Coin Exchange Issues Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 11679 accepted Submission (s): 7094


Problem Description in a country with only 1 cents, 2 cents, 3 cents, there are many ways to exchange money n coins. Please write a procedure to figure out how many kinds of methods are in common.
Input is only one positive integer per line n,n less than 32768.
Output corresponds to each input, the number of conversion methods.
Sample Input
2934 12553


Sample Output

718831 13137761
Author Smallbeer (CML)
Source Hangzhou Electronic ACM Team Training Competition (VII) Topic Resolution: This topic is a very simple knapsack problem, Dp[i] represents the value of I of the number of split methods, we only have direct burst to achieve the various can, very simple, 1A code:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 35000;
int DP[MAXN];
int main ()
{
    memset (dp,0,sizeof (DP));
    Dp[0] = 1;
    for (int i=1;i<=3;i++) for
        (int j=i;j<35000;j++)
            dp[j] = dp[j]+dp[j-i];
    int n;
    while (Cin>>n)
    {
        cout<<dp[n]<<endl;
    }
    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.