一切随心
编程菜园
博客园
首页
新随笔
联系
订阅
管理
数据加载中……
分硬币
/**/
/*
http://acm.hnu.cn
:8080/online/?action=problem&type=show&id=10415
*/
#include
<
iostream
>
#include
<
cstring
>
#include
<
vector
>
using
namespace
std;
int
main()
{
int
m;
//
硬币数目
int
v[
100
];
//
硬币面值
bool
isIn[
50001
];
//
硬币额度存在,则设置为true
vector
<
int
>
num;
//
所有能够获取的面额
int
i, j;
while
(cin
>>
m)
{
int
total
=
0
;
for
(i
=
0
; i
<
m; i
++
)
{
cin
>>
v[i];
total
+=
v[i];
}
memset(isIn,
false
,
sizeof
(isIn));
num.clear();
num.push_back(
0
);
for
(i
=
0
; i
<
m; i
++
)
{
int
length
=
num.size();
for
(j
=
0
; j
<
length; j
++
)
{
if
(
!
isIn[ v[i]
+
num[j] ])
{
isIn[ v[i]
+
num[j] ]
=
true
;
num.push_back(v[i]
+
num[j]);
}
}
}
for
(i
=
total
/
2
; i
>=
0
; i
--
)
{
if
(isIn[i])
{
cout
<<
total
-
i
-
i
<<
endl;
break
;
}
}
}
return
0
;
}
不要轻易认为就是Greedy了哈
posted on 2006-10-31 15:59
农夫三拳
阅读(166)
评论(0)
编辑
收藏
所属分类:
Algorithm
社区
新闻
新用户注册
刷新评论列表
标题
姓名
主页
Email
(只有博主才能看到)
验证码
*
看不清,换一张
[
登录
][
注册
]
内容(请不要发表任何与政治相关的内容)
Remember Me?
登录
使用高级评论
新用户注册
返回页首
恢复上次提交
[使用Ctrl+Enter键可以直接提交]
该文被作者在 2006-10-31 16:47 编辑过
所属分类的其他文章:
·
2007 South Central USA Regional Programming Contest 解题报告
·
Survey over pattern string match algorithm[6 items updated && to be continued]
·
图象处理基本算法[整理]
·
称球问题
·
过桥问题
·
货郎问题
·
灌水问题
·
关于Frobenius Number[整理]
·
K皇后问题
·
最大公约数(Gcd)两种算法(Euclid && Stein) [整理]
最新IT新闻:
·
第一财经周刊:当前互联网世界正处无秩序时代
·
Visual Studio 2008 SDK 1.1 发布
·
死敌VMware变身微软认证计划新成员
·
英特尔雅虎开发网络计算机频道
·
Windows Live视频邮件9月9日开始测试
博客园新闻频道
博客园首页
社区
<
2006年10月
>
日
一
二
三
四
五
六
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
统计
随笔 - 113
文章 - 0
评论 - 484
引用 - 3
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
留言簿
(5)
给我留言
查看留言
我参与的团队
蜘蛛游戏社团(0/208)
随笔分类
(113)
Algorithm(31)
(rss)
Asp.net(2)
(rss)
C#(20)
(rss)
C++(4)
(rss)
TopCoder(21)
(rss)
心情随笔(35)
(rss)
随笔档案
(112)
2008年8月 (2)
2008年6月 (2)
2008年5月 (1)
2008年4月 (1)
2008年3月 (1)
2008年2月 (1)
2008年1月 (1)
2007年10月 (8)
2007年9月 (2)
2007年8月 (1)
2007年7月 (2)
2007年6月 (3)
2007年5月 (7)
2007年4月 (13)
2007年3月 (17)
2007年2月 (6)
2007年1月 (10)
2006年12月 (8)
2006年11月 (8)
2006年10月 (16)
2006年9月 (2)
常去网站
CodeProject
CSDN
Joker's works
SourceForge
技术好友
&豪's Blog
(rss)
8600's Blog
(rss)
c4pt0r's Blog
(rss)
cockerel's blog
(rss)
Felicia's blog
flymouse's Blog
(rss)
imlazy's Blog
(rss)
Jin Bin's Blog
kaikai's blog
(rss)
linle's blog
(rss)
long1lfw's blog
(rss)
lower's blog
magicdlf's blog
(rss)
Matrix Chou's Blog
(rss)
NINSTEIN'S BLOG
(rss)
owen's blog
(rss)
richardxx's Blog
Roof's Blog
sicheng's blog
(rss)
Snoopy's Blog
(rss)
solary's blog
Solmyr`s Blog
(rss)
Suno阳's Blog
(rss)
tactoth's blog
TopBoy's Blog
(rss)
Vincent
(rss)
Willamette's Blog
(rss)
wuxyy's Blog
(rss)
wywcgs‘s blog
(rss)
yiyi's blog
zzningxp's Blog
(rss)
菜鱼.kitty's Blog
(rss)
尘离序散's Blog
海子's blog
火星's Blog
(rss)
极光炫影's Blog
(rss)
老罗's Blog
(rss)
茹枫's blog
(rss)
天地一线间's blog
(rss)
虚幻's Blog
(rss)
张磊's Blog
祗屬於我dě'sBlog
(rss)
同学
bear's Blog
(rss)
cb's blog
(rss)
CloudiDust's Blog
(rss)
Kai's Blog
(rss)
nicholas's Blog
(rss)
Nicky's Blog
(rss)
sql's Blog
(rss)
yangmin's Blog
(rss)
阿黄's Blog
(rss)
啤~酒~沫~沫~'s Blog
(rss)
秦岭
(rss)
最新随笔
1. 2007 South Central USA Regional Programming Contest 解题报告
2. 《C#完全手册》中提到的一些内部工具及编译选项
3. TC 泛黄了
4. Introduction to String Searching Algorithms--Rabin-Karp and Knuth-Morris-Pratt Algorithms [翻译]
5. TopCoder C# User List
6. TCHS SRM 1
7. Survey over pattern string match algorithm[6 items updated && to be continued]
8. 图象处理基本算法[整理]
9. eGroupWare 协同工作平台的搭建及使用
10. Dynamic Programming: From novice to advanced[翻译]
积分与排名
积分 - 69303
排名 - 576
最新评论
1. re: 货郎问题
#7楼
割平面法是一种处理方法,跟归不归到线性规划无关,就如分支定界一样。
--DarkMaster
2. re: TC 泛黄了
哈哈,牛啊 我也想变黄呢
--dlf
3. re: 最大公约数(Gcd)两种算法(Euclid && Stein) [整理]
@freesunshine
笔误,已修正,谢谢指点!
--农夫三拳
4. re: 最大公约数(Gcd)两种算法(Euclid && Stein) [整理]
这个地方似乎有误:“扩展欧几里德算法是用来在已知a, b求解一组p,q使得p * a+q * b = Gcd(p, q) ”,中的“Gcd(p,q)”应该改为“Gcd(a,b)”吧?
--freesunshine
5. re: 最大公约数(Gcd)两种算法(Euclid && Stein) [整理]
感谢大牛的整理,赞一个
--freesunshine
阅读排行榜
1. 东南大学2005年程序设计第二届初赛解题报告(2063)
2. .Net下WinForm换肤控件整理(1896)
3. Access 查询分析器1.0 发布了~(1701)
4. 有关Fibonacci题目的小结(1696)
5. Power up C++ with the Standard Template Library: Part I[翻译](1530)
评论排行榜
1. A bit of fun: fun with bits[翻译](29)
2. 北京之行--记Imagine Cup2007 软件设计(中国区)半决赛之旅(24)
3. Access 查询分析器1.0 发布了~(21)
4. 杭州之行--记杭电"网新恩普"杯程序设计邀请赛(17)
5. 东南大学2005年程序设计第二届初赛解题报告(14)