P1537 Marbles

Description

Masha and Bill each have their own marble collections. They want to redistribute the collections so that both of them have the same number of marbles. If all marbles had the same value, they could split them evenly. Unfortunately, some marbles are larger or more beautiful, so Masha and Bill assign each marble a value from $1$ to $6$. Now they want to divide the marbles so that each person receives the same total value. Unfortunately, they find that they may not be able to split the marbles this way (even if the total value of all marbles is even). For example, if there is one marble of value $1$, one of value $3$, and two of value $4$, then they cannot divide the marbles into two parts with equal value. Therefore, they want you to write a program to tell them whether it is possible to split all the marbles into two parts with equal total value.

Input Format

The input contains several lines, each with six non-negative integers $N_1,\cdots,N_6$, where $N_i$ is the number of marbles with value $i$. The maximum total number of marbles is up to $2\times 10^4$. The last line of the input is `0 0 0 0 0 0`. Do not process this line.

Output Format

For each dataset, output `Collection #k:`, where $k$ is the dataset number starting from $1$, followed by `Can be divided.` or `Can't be divided.`. Print an extra blank line after each dataset. You may refer to the sample.

Explanation/Hint

Translated by ChatGPT 5