[USACO2.3]货币系统 Money Systems
来源:互联网 发布:调查问卷软件 编辑:程序博客网 时间:2024/05/15 11:40
题目描述
母牛们不但创建了它们自己的政府而且选择了建立了自己的货币系统。由于它们特殊的思考方式,它们对货币的数值感到好奇。
传统地,一个货币系统是由1,5,10,20 或 25,50, 和 100的单位面值组成的。
母牛想知道有多少种不同的方法来用货币系统中的货币来构造一个确定的数值。
举例来说, 使用一个货币系统 {1,2,5,10,...}产生 18单位面值的一些可能的方法是:18x1, 9x2, 8x2+2x1, 3x5+2+1,等等其它。 写一个程序来计算有多少种方法用给定的货币系统来构造一定数量的面值。保证总数将会适合long long (C/C++) 和 Int64 (Free Pascal),即在0 到2^63-1之间。
输入输出格式
输入格式:货币系统中货币的种类数目是 V (1<=V<=25)。要构造的数量钱是 N (1<= N<=10,000)。
第一行: 二个整数,V 和 N 。
第二行: 可用的货币的面值 。
输出格式:
输出格式:单独的一行包含那个可能的用这v种硬币凑足n单位货币的方案数。
输入输出样例
输入样例#1:
3 101 2 5
输出样例#1:
10
说明
翻译来自NOCOW
USACO 2.3
【题解】
完全背包
/*ID:luojiny1LANG:C++TASK:money*/#include<cstdio>const int maxv=30,maxn=10100;long long s,d[maxn]={0};long long V,N;int main(){ freopen("money.in","r",stdin); freopen("money.out","w",stdout); scanf("%lld%lld",&V,&N); d[0]=1; for(int i=0;i<V;i++) { scanf("%lld",&s); for(int j=s;j<=N;j++) // for(int k=1;k*s<=j;k++)d[j]+=d[j-s]; } printf("%lld\n",d[N]); return 0;}
阅读全文
0 0
- [USACO2.3]货币系统 Money Systems
- usaco2.34Money Systems
- usaco2.3.4 Money Systems
- USACO2.3.4 Money Systems (money)
- USACO2.3.4 Money Systems (money)
- USACO / Money Systems货币系统(DP)
- 【DP】洛谷 P1474 货币系统 Money Systems
- 【USACO题库】2.3.4 Money Systems货币系统
- usaco2.3.4货币系统
- USACO-Section2.3 Money Systems
- Money Systems
- Money Systems
- Money Systems
- USACO section2.3 Money Systems题解&代码
- USACO 2.3 Money Systems (money)
- Section 2.3 Money Systems
- usaco: Money Systems
- usaco Money Systems
- Spring中Bean的简单属性注入
- 中文分词的python实现-基于HMM算法
- APC 基本概念及APC注入的实现(Ring3 + Ring0)----实现
- vs2012编译cocos2dx 3.10报错解决方法
- python中文错误
- [USACO2.3]货币系统 Money Systems
- hdu 5008 (后缀数组 + rmq +二分)
- Request头和Response头
- Java实现AES的128、256位密钥加解密算法 并 解决Illegal key size or default parameters问题
- Python 浅拷贝 深拷贝 及引用机制
- Linux github提交方法
- 解决Win7系统无法睡眠问题
- 1702
- C++中memset函数的用法注意事项