#P6552. 文具订购(加强版)
文具订购(加强版)
Description
Xiaoming’s class has a total class fund of yuan. The students plan to use the fund to collectively buy types of items:
- Compass, yuan each.
- Pen, yuan each.
- Notebook, yuan each.
Xiaoming is in charge of ordering the stationery. Let the ordered quantities of compasses, pens, and notebooks be respectively. His ordering rules, in order, are:
- The yuan must be spent exactly, i.e. .
- Subject to the above condition, the number of complete sets should be as large as possible, i.e. the minimum of should be as large as possible.
- Subject to the above conditions, the total number of items should be as large as possible, i.e. should be as large as possible.
Please help Xiaoming find the optimal plan that satisfies the conditions. The data guarantees that . If there are multiple solutions, output the lexicographically smallest answer .
Input Format
The input contains multiple test cases. The first line contains an integer , indicating the number of test cases.
The next lines each contain four integers: the class fund , and the prices of the three items.
Output Format
For each test case, if there is no solution, output .
Otherwise, output one line with three integers separated by spaces: , representing the number of compasses, pens, and notebooks.
3
33 7 4 3
81 39 37 7
227200291 189101 133029 52503
1 2 6
1 0 6
446 845 580
Hint
For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号