Marbles

2020年1月17日 1146点热度 0人点赞 0条评论

Marbles

时间: 1ms        内存:64M

描述:

I collect marbles (colorful small glass balls) and want to buy boxes to store them. The boxes come in two types:

Type 1:
each such box costs c1 dollars and can hold exactly n1 marbles
Type 2:
each such box costs c2 dollars and can hold exactly n2 marbles
I want each box to be filled to its capacity, and also to minimize the total cost of buying them. Help me find the best way to distribute my marbles among the boxes.

输入:

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, c1, c2, n1, and n2 are all positive integers having values smaller than 2,000,000,000. A test case containing a zero for the number of marbles terminates the input.

输出:

For each test case in the input print a line containing the minimum cost solution (two nonnegative integers m1 and m2, where mi = number of type i boxes required if one exists. Otherwise print ``failed''.
If a solution exists, you may assume that it is unique.

示例输入:

43
1 3
2 4
40
5 9
5 12
0

示例输出:

13 1
failed

提示:

参考答案:

解锁文章

没有看到答案?微信扫描二维码可免费解锁文章

微信扫描二维码解锁

使用微信扫描二维码打开广告页面后可以立即关闭,再刷新此页面即可正常浏览此文章

所跳转广告均由第三方提供,并不代表本站观点!

已经扫描此二维码?点此立即跳转

code

这个人很懒,什么都没留下

文章评论