N items are to be processed with two product lines. YY operates the first line, and LMY operates the second. YY can use X processing modes for the first product line, with his ith mode, processing an item costs Ai units of material while the item’s value increases by Pi units. Similarly LMY can use Y modes for the second product line, with her ith mode processing an item will cost Bi units of material and get Qi units of value increment. All items must be processed in both of the product lines, each with one of their modes, to satisfy both YY and LMY. Note that when processing an item with some mode of a product line, the cost and value increment are totally irrelevant to the mode chosen in the other line. YY and LMY want the value increment of the items to be maximized, but there are only M units of material available. So they have to choose their modes carefully, use no more than M units of material and still make the value increment as large as possible.
Input contains multiple test cases.
For each test case, there is only one single line consisting of 8 integers with absolute value no larger than 1000: R, r, x0, y0, z0, x1, y1, z1, indicating the radii of the sun and the moon, the location of the moon, and the location of YY. R and r are always positive.
A line with 8 space-separated 0s indicates the end of input.
3 1 5 0 0 10 0 0
0 0 0 0 0 0 0 0
annular eclipse
Migrated from old NTUJ.
2009 Shanghai Network Contest
No. | Testdata Range | Score |
---|