POJ2142_The Balance_扩展欧几里得

博客介绍了如何利用扩展欧几里得算法解决使用两种不同质量砝码称出指定质量药品的问题。在多种合法方案中,需要找到砝码数量最少且总质量最小的解。通过建立方程并转换为扩展欧几里得方程,将问题转化为求解该方程的正整数解,并提供了相应的代码实现。
摘要由CSDN通过智能技术生成

The Balance
Time Limit: 5000MS   Memory Limit: 65536K
Total Submissions: 6456   Accepted: 2840

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 use more weights. 
You are asked to help her by calculating how many weights are required. 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值