USACO 2.3 Money Systems (DP 动态规划 + 空间优化)
来源:互联网 发布:淘宝充值软件利润 编辑:程序博客网 时间:2024/05/21 01:56
#include <stdio.h>#define DEBUG 1#define TESTCASES 9//ways[constructedMoney]表示凑成constructedMoney的数量的钱时的方案数long long ways[10001];int main(){#if DEBUGint testCase;for (testCase = 1; testCase <= TESTCASES; testCase++){char inputFileName[20] = "inputX.txt";inputFileName[5] = '1' + (testCase - 1);freopen(inputFileName, "r", stdin);printf("\n#%d\n", testCase);#endif int typesOfCoins, moneyToConstruct; scanf("%d%d", &typesOfCoins, &moneyToConstruct); int constructedMoney; for (constructedMoney = 1; constructedMoney <= moneyToConstruct; constructedMoney++) ways[constructedMoney] = 0; ways[0] = 1; int type; for (type = 1; type <= typesOfCoins; type++){ int coinsValue; scanf("%d", &coinsValue); for (constructedMoney = coinsValue; constructedMoney <= moneyToConstruct; constructedMoney++) ways[constructedMoney] += ways[constructedMoney - coinsValue]; }printf("%lld\n", ways[moneyToConstruct]);#if DEBUG}#endifreturn 0;}
0 0
- USACO 2.3 Money Systems (DP 动态规划 + 空间优化)
- USACO 2.3 Money Systems (DP 动态规划)
- 【动态规划】【USACO】Money Systems
- USACO--2.3Money Systems+dp
- USACO section 2.3 Money Systems(dp)
- USACO-Section 2.3 Money Systems(DP)
- USACO 2.3Money Systems(简单DP)
- USACO 2.3 Money Systems (money)
- USACO 2.3.4 Money Systems
- USACO 2.3.4 Money Systems
- USACO 2.3 Money Systems 题解
- USACO / Money Systems货币系统(DP)
- usaco: Money Systems
- usaco Money Systems
- USACO-Money Systems
- usaco Money Systems
- USACO-Money Systems
- USACO :Money Systems解题报告
- KT学算法(三)——最长回文子串与Manacher算法
- Apache Struts 2的命名空间实战
- java学习_IO(2)
- A840S黑砖修复过程(2013-05-22修改)
- matlab中运用项目思维分析问题并解决问题
- USACO 2.3 Money Systems (DP 动态规划 + 空间优化)
- 深入理解javascript原型链
- leetcode 16 3Sum Closet
- 安卓控件使用系列24:Gallery画廊控件的使用方法
- HighCharts坐标轴Y轴倒过来画图
- java nio 高级
- 组合数与错排数求解方法探析
- HighCharts设置多个Y轴 Y轴位置
- 非静态成员引用必须与特定对象相对