uva674 Coin Change ——完全背包
link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=615
和完全背包一样的思想。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
const int dir[][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
using namespace std;
int a[]={,,,,};
int f[];
int main(void)
{
ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int n;
while (cin>>n) {
memset(f,,sizeof(f)); f[]=;
for (int i = ; i < ; ++i) {
for (int j=a[i]; j<=n;++j) {
f[j]+=f[j-a[i]];
}
}
cout<<f[n]<<endl;
}
return ;
}
o(╯□╰)o
认真理解一下这种思想就行了。不难
uva674 Coin Change ——完全背包的更多相关文章
- UVA-674 Coin Change---完全背包
题目链接: https://vjudge.net/problem/UVA-674 题目大意: 有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 思路: 每 ...
- Light oj 1233 - Coin Change (III) (背包优化)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1233 题目就不说明了. 背包的二进制优化,比如10可以表示为1 2 4 3,而 ...
- UVA.674 Coin Change (DP 完全背包)
UVA.674 Coin Change (DP) 题意分析 有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 每种硬币的数量是无限的.典型完全背包. 状态 ...
- Lightoj 1231 - Coin Change (I) (裸裸的多重背包)
题目链接: Lightoj 1231 - Coin Change (I) 题目描述: 就是有n种硬币,每种硬币有两个属性(价值,数目).问用给定的硬币组成K面值,有多少种方案? 解题思路: 赤果果的 ...
- hdu 2069 Coin Change(完全背包)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- C - Coin Change (III)(多重背包 二进制优化)
C - Coin Change (III) Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu ...
- Coin Change (II)(完全背包)
Coin Change (II) Time Limit: 1000MS Mem ...
- UVA 674 Coin Change(dp)
UVA 674 Coin Change 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/ ...
- LightOJ - 1232 - Coin Change (II)
先上题目: 1232 - Coin Change (II) PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: ...
随机推荐
- KO Demo
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- git的一些常用方法
1.撤销add但未commit的文件: git rm -r --cached path/file 2.git 撤销commit: 2.1).git log-显示提交的历史 commit ee50348 ...
- Linux系统信息查看
转自:http://blog.chinaitlab.com/html/31/1365331-180901.html 查看redhat版本:cat /etc/redhat-release或者cat /e ...
- Android Studio build dex jar
Gradle配置 Build配置文件gradle.build中添加如下task task clearJar(type: Delete) { delete 'build/outputs/mylib.ja ...
- Laravel 5 使用中的问题记录(持续更新)
1.更新了blade模板却没有更新缓存 通过使用ftp上传文件到服务器,更新了blade模板,却没有更新缓存,经查,原因是系统时间的影响,通过ftp上传的模板文件修改时间与缓存文件的时间不一致,导致模 ...
- 无法嵌入互操作类型“Microsoft.Office.Interop.Excel.ApplicationClass”。请改用适用的接口
解决 把Microsoft.Office.Interop.Excel.DLL的嵌入互操作类型改为ture就可以了
- 读<jquery 权威指南>[1]-选择器及DOM操作
今天是小年了,2013马上要过去了,但是学习不能间断啊.最近正在看<jQuery权威指南>,先温习一下选择器和DOM操作. 一.基本选择器 1.table单双行: $(function ( ...
- Python中 filter | map | reduce | lambda的用法
1.filter(function, sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tupl ...
- Octopus系列之代码备份
代码 $.extend($.validator.messages, { required: "This field is required.", remote: "Ple ...
- Hash哈希类型
hash类型是使用得非常非常多的一种redis数据类型,相当于C#中的Dictionary和Hashtable. hset命令(语法:hset key field value)将哈希表key中的fie ...