| 
 
 钱币兑换问题  Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)  Total Submission(s): 18088 Accepted Submission(s): 10838  
Problem Description  在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。  
Input  每行只有一个正整数N,N小于32768。  
Output  对应每个输入,输出兑换方法数。  
Sample Input  2934  12553  
Sample Output  718831  13137761  
Author  SmallBeer(CML)  
Source  杭电ACM集训队训练赛(VII)  
问题链接:HDU1284 钱币兑换问题  问题简述:(略)  问题分析:完全背包的简单题,不解释。  程序说明:(略)  参考链接:(略)  题记:(略)  
AC的C++语言程序如下:  
#include <bits/stdc++.h>
using namespace std;
const int C = 3;
const int N = 32768;
int dp[N + 1];
int main()
{
    memset(dp, 0, sizeof dp);
    dp[0] = 1;
    for (int i = 1; i <= C; i++)
        for (int j = i; j <= N; j++)
            dp[j] += dp[j - i];
    int n;
    while (~scanf("%d", &n))
        printf("%d\n", dp[n]);
    return 0;
}
 
                
                
                
        
        
    
  
 
 |