UVA 147 Dollars ( 完全背包+求解方案数精度问题)
来源:互联网 发布:释行宇谭腿 知乎 编辑:程序博客网 时间:2024/05/17 22:54
UVA 147 Dollars
11种金币,输出能组成给定数额的方法个数。注意精度问题
#include <cstdio> #include <cstring> const int N = 11; const int maxn = 30005; const int c[N] = {5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000}; //硬币分值 long long f[maxn]; int main () { float num; int n; while (1) { scanf ("%f", &num); n = (num + 0.005) * 100; //进行数值处理,转换为整数 memset (f, 0, sizeof (f)); //初始化 f[0] = 1; for (int i = 0; i < N; i++) { for (int j = c[i]; j <= maxn - 5; j++) { f[j] += f[j - c[i]]; }} if (!n) break; //遇零跳出 printf ("%6.2f%17lld\n", num, f[n]); //注意输出格式 } return 0; }
0 0
- UVA 147 Dollars ( 完全背包+求解方案数精度问题)
- uva 147 - Dollars 钱币兑换问题(浮点数) 精度问题 完全背包
- Uva 147 Dollars 完全背包
- Uva 147 Dollars 完全背包
- uva 147 Dollars(完全背包)
- UVa 147 Dollars (完全背包)
- UVA 147 - Dollars(完全背包)
- UVA 147 Dollars (完全背包)
- uva 147 Dollars(完全背包)
- UVA - 147 Dollars(完全背包)
- UVA 147 Dollars 完全背包
- UVA 147 dollars (背包方案数 )(浮点数问题)
- UVA 674 Coin Change(完全背包+求解方案数)
- uva 147 Dollars (dp + 完全背包)
- uva 147 Dollars(完全背包)
- UVA 147 Dollars 完全背包 Commencel
- UVa 147 Dollars(DP完全背包)
- UVa 147 Dollars(DP完全背包)
- MyBatis--查询缓存--内置二级缓存的使用原则
- 谈谈程序员的焦虑感
- Hadoop 性能优化
- sprintf 字符串格式化
- 剑指offer--跳台阶
- UVA 147 Dollars ( 完全背包+求解方案数精度问题)
- 【Linux】让Ubuntu 支持 GBK等字符集,解决中文乱码
- 算法导论 Exercise 2.3-5 (implement binary serach recursively)
- uva816 -- Abbott's Revenge (BFS)
- 洛谷3467 [POI2008]PLA-Postering 单调栈
- 122. Best Time to Buy and Sell Stock II
- atexit函数
- Android.mk详解
- PyQt——结合Python与Qt的GUI编程