uva357
来源:互联网 发布:java list 获取第一个 编辑:程序博客网 时间:2024/05/18 03:26
题目大意:
给定一些面值的钱币,问你有几种方法可以拼凑成要求的价格。
思路:
动态规划
代码:
#include <iostream>using namespace std;#include <cstring>#include <stdio.h>int coin[5] = {1,5,10,25,50};long long dp[30010];int main() { int n;// memset(dp,1,sizeof(dp)); dp[0] = 1; for(int i = 0; i < 5;i++) { for(int j = 0; j < 30000; j++) dp[j + coin[i]] += dp[j]; } while(scanf("%d",&n)!=EOF){ if(dp[n] == 1) printf("There is only %d way to produce %d cents change.\n",1,n); else printf("There are %lld ways to produce %d cents change.\n",dp[n],n); } return 0;}
0 0
- uva357
- uva357
- uva357
- uva357
- uva357 Let Me Count The Ways
- [动态规划]UVA357 - Let Me Count The Ways
- uva357 - Let Me Count The Ways(动规,母函数)
- UVa357 Let Me Count The Ways DP多阶段决策问题
- 如何在lk中修改gpio的值
- The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (i
- UILabel的一些用法
- 简易发送短信app
- 大型网站架构系列:负载均衡详解(2)
- uva357
- linux kernel 动态输出模块调试log的方法
- 工作笔记day02
- 福利,一张图看懂IT售前工程师修炼之道
- Android 通过JNI实现守护进程,使Service服务不被杀死
- 设计模式—策略模式
- 解决php的“It is not safe to rely on the system’s timezone settings”问题
- WEB开发者应必须具备的6大技能
- 使用myeclipse2014提交项目至git oschina