HDU1284 钱币兑换问题

来源:互联网 发布:微信群抽奖软件 编辑:程序博客网 时间:2024/04/30 16:01

Problem Description
在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。
 

Input
每行只有一个正整数N,N小于32768。
 

Output
对应每个输入,输出兑换方法数。
 

Sample Input
293412553
 

Sample Output
71883113137761

#include <iostream>using namespace std;long dp[32770];int main(){freopen("C:\\in.txt","r",stdin);int money;dp[0]=1;for(int i=1;i<=3;i++)for(int j=i;j<=32768;j++)dp[j]+=dp[j-i];while(scanf("%d",&money)!=EOF){printf("%ld\n",dp[money]);}return 0;} 


0 0
原创粉丝点击