QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 10

#2127. Bottles [C]

Estadísticas

Byteasar has 3 bottles partially filled with soda. He would now like to pour soda from one bottle to another to reach a situation where one of them contains exactly $k$ byte-liters of soda. Since he does not have a scale at home, the only allowed operation is pouring soda between any two bottles – either until the bottle from which he is pouring becomes empty, or until the bottle into which he is pouring becomes full. It is forbidden to spill soda on the ground – after all, the soda is too precious! Byteasar also cannot add new soda to the bottles from outside his three bottles.

Byteasar is now wondering, for every $k$, what is the minimum number of pours required so that any bottle contains exactly $k$ byte-liters of soda. He is counting on you to do it!

Input

The first line of input contains three integers $A, B, C$ ($1 \le A \le B \le C \le 10^5$), representing the capacities of the first, second, and third bottle in byte-liters, respectively.

The second line of input contains three integers $a, b, c$ ($0 \le a \le A, 0 \le b \le B, 0 \le c \le C$), representing how many byte-liters of soda are initially in the first, second, and third bottle, respectively.

Output

The output should contain $C + 1$ integers; the $i$-th of these should represent the minimum number of pours after which one of the bottles can contain exactly $i - 1$ byte-liters of soda, or $-1$ if it is impossible to obtain that volume of soda regardless of the operations performed.

Examples

Input 1

2 7 9
1 3 6

Output 1

1 0 1 0 1 1 0 1 2 1

Note

Explanation of the example: The result for 1, 3, and 6 byte-liters is 0 – we already have bottles with these volumes of soda at the beginning.

To obtain 0 byte-liters, it is enough to pour soda from the first bottle into the second or third bottle. Then the first bottle will become empty. We could also pour soda from the second to the third bottle. Then the second bottle would become empty.

To obtain 2 byte-liters, it is enough to pour soda from the second or third bottle into the first. Then there will be exactly 2 byte-liters in the first bottle.

To obtain 4 byte-liters, it is enough to pour soda from the first bottle into the second. Then there will be exactly 4 byte-liters in the second bottle.

To obtain 5 byte-liters, it is enough to pour soda from the third bottle into the first. Then there will be exactly 5 byte-liters in the third bottle.

To obtain 7 byte-liters, it is enough to pour soda from the first bottle into the third. Then there will be exactly 7 byte-liters in the third bottle.

To obtain 9 byte-liters, it is enough to pour soda from the second bottle into the third. Then there will be exactly 9 byte-liters in the third bottle.

Obtaining 8 byte-liters requires two pours. First, we pour soda from the second bottle into the third, and then from the third to the first. Then exactly 8 byte-liters of soda will remain in the third bottle.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.