传送门

Coin Change

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 20297    Accepted Submission(s): 7136

Problem Description
Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money.

For example, if we have 11 cents, then we can make changes with one 10-cent coin and one 1-cent coin, or two 5-cent coins and one 1-cent coin, or one 5-cent coin and six 1-cent coins, or eleven 1-cent coins. So there are four ways of making changes for 11 cents with the above coins. Note that we count that there is one way of making change for zero cent.

Write a program to find the total number of different ways of making changes for any amount of money in cents. Your program should be able to handle up to 100 coins.

Input
The input file contains any number of lines, each one consisting of a number ( ≤250 ) for the amount of money in cents.
Output
For each input line, output a line containing the number of different ways of making changes with the above 5 types of coins.
Sample Input
  
11 26
Sample Output
  
4 13
Author
Lily
Source
浙江工业大学网络选拔赛
Recommend
linle
板子留给自己用的。  
//china no.1
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <stack>
#include <cstring>
#include <queue>
#include <list>
#include <stdio.h>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>
#include <functional>
#include <stdlib.h>
#include <time.h>
#include <bitset>
using namespace std;#define pi acos(-1)
#define endl '\n'
#define srand() srand(time(0));
#define me(x,y) memset(x,y,sizeof(x));
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define close() ios::sync_with_stdio(0); cin.tie(0);
#define FOR(x,n,i) for(int i=x;i<=n;i++)
#define FOr(x,n,i) for(int i=x;i<n;i++)
#define W while
#define sgn(x) ((x) < 0 ? -1 : (x) > 0)
#define bug printf("***********\n");
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL LINF=0x3f3f3f3f3f3f3f3fLL;
const int dx[]={-1,0,1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,-1,1,-1,1};
const int maxn=1e3+10;
const int maxx=3e5+100;
const double EPS=1e-7;
const int mod=10000007;
#define mod(x) ((x)%MOD);
template<class T>inline T min(T a,T b,T c) { return min(min(a,b),c);}
template<class T>inline T max(T a,T b,T c) { return max(max(a,b),c);}
template<class T>inline T min(T a,T b,T c,T d) { return min(min(a,b),min(c,d));}
template<class T>inline T max(T a,T b,T c,T d) { return max(max(a,b),max(c,d));}
inline LL Scan()
{int f=1;char C=getchar();LL x=0;while (C<'0'||C>'9'){if (C=='-')f=-f;C=getchar();}while (C>='0'&&C<='9'){x=x*10+C-'0';C=getchar();}x*=f;return x;
}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.out" , "w" , stdout );
//cerr << "run time is " << clock() << endl;int n,a[maxn][105],b[maxn][105],i,j,k,l,v[18]={0,1,5,10,25,50};
int main()
{//freopen( "in.txt" , "r" , stdin );while (scanf("%d",&n)!=EOF){memset(a,0,sizeof(a));memset(b,0,sizeof(b));for(i=0;i<=100;i++) a[i][i]=1;for(i=2;i<=5;i++){//maxx+=num[i]*money[i];for(j=0;j<=n;j++)for(k=0;k+j<=n;k+=v[i])//for(int k=0;k<=num[i]&&j+k*v[i]<=maxx;k++)for(l=0;l+k/v[i]<=100;l++)b[k+j][l+k/v[i]]+=a[j][l];for(k=0;k<=n;k++)for(l=0;l<=100;l++){a[k][l]=b[k][l];b[k][l]=0;}}int sum=0;for(int i=0;i<=100;i++)sum+=a[n][i];cout<<sum<<endl;}return 0;
}
/*
for(int i=1;i<=3;i++)
{maxx+=num[i]*money[i];for(int j=0;j<=maxx;j++)for(int k=0;k<=num[i] && j+k*money[i]<=maxx;k++)c2[j+k*money[i]]+=c1[j];for(int j=0;j<=maxx;j++){c1[j]=c2[j];c2[j]=0;}
}
*/

HDU 2069 母函数模版题相关推荐

  1. hdu 1028 母函数 模版题

    母函数详解 http://www.wutianqi.com/?p=596 第二种: 求用1分.2分.3分的邮票贴出不同数值的方案数: 大家把这种情况和第一种比较有何区别?第一种每种是一个,而这里每种是 ...

  2. hdu 1028 母函数入门题

    点击打开链接 题意:给出n n<=120,拆分n的方法数? (1+x^2+x^3+..x^n) *(1+x^2+x^4+x^6+...) *(1+x^3+x^6+...)  第i个表达式代表了数 ...

  3. hdu 1286 找新朋友 欧拉函数模版题

    找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Des ...

  4. 畅通工程(并查集模版题)

    题意: 多组输入N,M,当N为0退出人输入,N是道路数目,M是村庄总数,随后N行,每行输入三个数两个村庄的编号,以及连接这两个村庄的费用. 对每一组数据输出畅通工程的最低费用,如果不能畅通就输出&qu ...

  5. 【AC梦工厂】最大流hdu1532模版题

    问题:调控水流从s点经过许多不同容量的水管到达t点的使得流量最大值的问题 概念解释: G(u,v)代表图中的路 c(u,v)代表路的容量 f(u,v)代表的是当前路的流量 r(u,v)代表还能够增加的 ...

  6. HDU2896(AC自动机模版题)

    AC自动机模版题: 方法一:超时 #include<iostream> #include<algorithm> #include<cstring> #include ...

  7. HDU 5703 Desert 水题 找规律

    HDU 5703 Desert 水题 找规律 已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现 ...

  8. PAT (Top Level) Practise 1008 Airline Routes(Tarjan模版题)

    1008. Airline Routes (35) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Given a ...

  9. POJ 2387 Til the Cows Come Home (最短路径 模版题 三种解法)

    原题链接:Til the Cows Come Home 题目大意:有  个点,给出从  点到  点的距离并且  和  是互相可以抵达的,问从  到  的最短距离. 题目分析:这是一道典型的最短路径模版 ...

最新文章

  1. 常用的数据统计Sql 总结(转)
  2. 基于分类任务的信号(EEG)处理
  3. iOS 代理反向传值
  4. hbase-admin:一款简陋的hbase数据查询工具(支持2.2.6)
  5. 【本人秃顶程序员】技巧分享丨spring的RestTemplate的妙用,你知道吗?
  6. 前端学习(2154):webpack横幅plugin的使用
  7. DataBinding注意事项Error parsing XML: duplicate attribute以及如何在listview中使用DataBinding...
  8. eclipse-sql server 2008连接
  9. python使用ssh 中文_使用Python进行SSH的最简单方法是什么?
  10. PHP 验证日期格式
  11. 交换机配置snmp及查看snmp配置信息
  12. 图着色问题(超详细!!!)
  13. html5 等比压缩图片,图片上传裁剪amp;等比缩放处理(html5+Canvas)
  14. windows远程连接不能复制粘贴
  15. 如何让自己发了疯、拼了命、石乐志的学习?
  16. win10怎么设置计算机语言,Win10系统怎么设置中文语言_windows10怎么把系统语言设置成中文...
  17. 中国芯片的突破带来压力,美国芯片龙头将再度裁员,或已后悔不迭
  18. Vue2.0 组件文本超出3行显示... 点击查看更多可以查看全部内容(展开收起)
  19. HQL怎么用身份证计算年龄
  20. 让你的windows死机的bat

热门文章

  1. 用队列实现栈--用两个队列模拟实现栈
  2. 代码发芽网更新了22个颜色主题
  3. 金融机构移动办公安全管控难?要如何解决?
  4. Unity顶点绘制工具VertPaint
  5. qt版——操作系统课程设计(含可视化界面)
  6. 详谈如今的Servlet
  7. 在Outlook 2010中查看您的Google日历
  8. php 图片等比缩小图片,php 图片比例缩放代码
  9. Oracle Secure Backup管理员指南 第7章 管理磁带设备
  10. php取qq空间日志说说,qq空间霸气说说心情