若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1548: Marbles

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,194

题目描述

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


参考代码

暂无

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

原站点 Dreams孤独患者 Skip
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist