uva 10090 marbles

该问题描述了一个需要以最低成本购买两种不同类型的盒子来存储大理石的情况。类型1的盒子每个成本c1,能装n1个大理石,类型2的盒子每个成本c2,能装n2个。输入包含多个测试用例,每个用例给出大理石数量n,以及两种盒子的成本和容量。输出应提供一种解决方案,即每种类型盒子所需的数量,如果存在,则保证盒子被填满且成本最低。如果不存在解决方案,则输出"failed"。
摘要由CSDN通过智能技术生成

Problem F

Marbles

Input: standard input

Output: standard output

 

I have some (say, n) marbles (small glass balls) and I am going to buy some boxes to store them. The boxes are of two types:

 

Type 1: each box costs c1 Taka and can hold exactly n1 marbles

Type 2: each box costs c2 Taka and can hold exactly n2 marbles

 

 

I want each of the used boxes to be filled to its capacity and also to minimize the total cost of buying them. Since I find it difficult for me to figure out how to distribute my marbles among the boxes, I seek your help. I want your program to be efficient also.

 

Input

The input file may contain multiple test cases. Each test case begins with a line containing the integer n (1 <= n <= 2,000,000,000). The second line contains c1 and n1, and the third line contains c2 and n2. Here, c1c2, <

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值