uva 357 - Let Me Count The Ways
来源:互联网 发布:python time sleep作用 编辑:程序博客网 时间:2024/05/17 06:50
#include <cstdio>#include <cstring>#include <cctype>#include <cstdlib>#include <queue>#include <stack>#include <cmath>#include <string>#include <iostream>#include <algorithm>using namespace std;#define maxn 30000 + 10#define INF 2100000000#define ll long longint v[8] = {1, 5, 10, 25, 50};ll dp[8][maxn];ll DP(int i, int j){ if(dp[i][j] != -1) return dp[i][j]; dp[i][j] = 0; for(int k = 0; j - k * v[i] >= 0; ++k) dp[i][j] += DP(i-1, j-k*v[i]); return dp[i][j];}int main(){ int n; memset(dp, -1, sizeof(dp)); while(scanf("%d", &n) != EOF) { for(int i = 0; i <= n; ++i) dp[0][i] = 1;//用前i种钱组成j ll ans = DP(4, n); if(ans == 1) printf("There is only 1 way to produce %d cents change.\n", n); else printf("There are %lld ways to produce %d cents change.\n", ans, n); } return 0;}
0 0
- uva 357 Let Me Count The Ways
- uva 357 - Let Me Count The Ways
- UVA 357 Let Me Count The Ways
- UVA 357 Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- uva 357 let me count the ways
- UVa 357 - Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- UVA-357-Let Me Count The Ways
- UVA 357 Let Me Count The Ways
- UVa:357 Let Me Count The Ways
- UVa 357: Let Me Count The Ways
- UVA - 357 Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- uva 357 Let Me Count The Ways
- uva 357 - Let Me Count The Ways
- uva 357 Let Me Count The Ways
- NYOJ 题目168 房间安排
- 【原创】IDA调试dex代码初体验
- hadoop环境搭建
- 利用共享内存来恢复玩家数据
- Optimistic locking---PoEAA
- uva 357 - Let Me Count The Ways
- iOS中七种手势
- viewController 和 tableView 相关方法执行顺序及作用
- Matlab mser(最大极值稳定区域)
- UITableView学习笔记
- Boost::asio io_service 实现分析
- Swift学习这十七:重载(override)
- 冒泡排序(Objective-C --- NSMutableArray类目版)
- 浅谈Java类与对象的概念区别