钱币兑换问题(完全背包)
2015-07-24 16:51
155 查看
钱币兑换问题
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7465 Accepted Submission(s): 4407
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)
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> const int N=32770; using namespace std; int dp ; int main() { int n,i,j; while(cin>>n) { memset(dp,0,sizeof(dp)); dp[0]=1; for(i=1;i<=3;i++) { for(j=i;j<=n;j++) { dp[j]=dp[j-i]+dp[j]; } } cout<<dp <<endl; } }
相关文章推荐
- RobotFramework 数据分离
- RobotFramework 数据分离
- DNS及DNS主从配置
- linux 下格式化U盘,制作U盘启动盘
- Android延时执行调用的几种方法(转)
- 最小生成树算法
- http\r\n
- Ubuntu系统下的Hadoop集群(1)_Hadoop安装教程_单机/伪分布式配置
- Spring boot 学习知识点
- jsoncpp-0.5,支持uint64
- angularjs图片上传后不刷新的解决办法
- Shell根据年月日创建文件夹
- java中Cookie的使用
- Java构造和解析Json数据的两种方法详解
- cocos2d-x中文乱码问题解决
- 008华为机试分解字符串,M,N问题
- open函数后面参数'a','w','r'的区别
- 虚函数的工作原理
- 机器学习(4)——logistic regression
- localhost与127.0.0.1之间的区别