poj-2142 The Balance 扩展欧几里德算法

该博客详细介绍了如何应用扩展欧几里德算法来解决POJ上的2142题——The Balance。题目要求通过两种不同重量的砝码,以最小数量和总重量找出平衡物品重量的方法。博客首先解析了题目需求,然后展示了如何将问题转化为求解绝对值之和最小的方案,并在存在多解时确保砝码总质量最小。博主给出了C++代码实现,该代码在提交时获得了0ms的运行时间。
摘要由CSDN通过智能技术生成

题目链接

poj-2142 The Balance

题目

The Balance
Time Limit: 5000MS   Memory Limit: 65536K
Total Submissions: 8015   Accepted: 3506

Description

Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine. For example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the side of the medicine and three 300mg weights on the opposite side (Figure 1). Although she could put four 300mg weights on the medicine side and two 700mg weights on the other (Figure 2), she would not choose this solution because it is less convenient to
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值