c语言砝码称重,浅谈砝码称重问题的两种算法 - atlantis press.pdf

浅谈砝码称重问题的两种算法 - atlantis press

International Conference on Education, Management and Computer Science (ICEMC 2016)

Two Algorithms for Weight Problems

1, a 1 1, b 1 1

Chun Shi , Xin Yin , Chunyu Li , Ruyin Xu and Shuqian He

1Lab. Digital Medium, School of Information Science & Technology, Hainan Normal University,

Haikou, Hainan 571127, China

abyshichun@, blichunyu_hn@126.com

Keywords: Weight problem; Greedy algorithm; Dynamic programming; C++

Abstract. Research on weight problem is helpful to solve other problems, and it has practical

significance for the design of the algorithm and the solution of the real life. The purpose of this

paper is to introduce the solution for the weight problem with both greedy algorithm and dynamic

programming. We mainly discuss the difference between these two algorithms based on different

solution methods. The algorithms in this paper are described in C language, natural language or

charts.

浅谈砝码称重问题的两种算法

1,a 1 1,b 1 1

石春 ,尹鑫 ,李春雨 ,许茹茵 ,何书前

1.海南师范大学 信息科学技术学院,海南 海口 571127

a b

shichun@, lichunyu_hn@126.com

摘要:砝码称重问题的研究有助于解决其它各种拓展出的问题,对算法设计和实际生活中问题

的解决都具有现实的意义。对砝码称重问题,用贪心算法与动态规划两种方法求解。从求解

思路介绍两种算法的差异。算法使用C 语言,自然语言以及图表描述。

关键词:称重问题; 贪心算法; 动态规划; C++

1. 引言

在算法学习和研究过程中,针对同一个问题,采用不同的算法进行分析,可以有效加深对算

法特征的理解,同时也为解决其他问题开拓了更广阔的思路[1][2]。

砝码称重是算法分析中一个经典的问题,已经有学者从多个方面进行了探讨[2][3][4],本文

尝试从贪心算法[5][6]和动态规划[7][8]给出算法解决方案之间的差异。

2. 砝码称重的问题描述

设有1g,2g,5g 的砝码各若干枚。试设计算法,计算可用这些砝码称出多少种不同的重量。

例如,有 1g,2g,5g 的砝码各1 枚,则可用它们称出 1g,2g,3g,5g,6g,7g,8g 共7 种

不同的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值