| Abakoda Long Contest 2022 |
|---|
| Finished |
The moon drives me crazy
Ugh, the moonlight drives me nuts!
It's such an eyesore!
Alice is volunteering at a magical bunny farm in order to earn some extra credit for her biology class! Magical bunnies are peculiar in that each one can only be in one of three possible states: young, mature, or old.
The farm initially has $$$a$$$ young bunnies, $$$b$$$ mature bunnies, and $$$c$$$ old bunnies. Whenever Alice sacrifices a magical Moon Stone, the following three things happen simultaneously:
For her own personal reasons, Alice wants the farm to have $$$d$$$ young bunnies, $$$e$$$ mature bunnies, and $$$f$$$ old bunnies. However, she knows that getting those exact quantities is unlikely. So, she instead settles for aiming to be as close to her target as possible, for some definition of "close".
Suppose that currently, the farm has $$$x$$$ young bunnies, $$$y$$$ mature bunnies, and $$$z$$$ old bunnies. Then, Alice uses the following formula to compute the "square error": $$$$$$\begin{align*} \text{square error} ~ = (x - d)^2 + (y - e)^2 + (z - f)^2. \end{align*}$$$$$$
Find the minimum possible value of the square error, and also the minimum number of magical Moon Stones that Alice needs to sacrifice in order to achieve it.
Also, you must answer $$$T$$$ different test cases.
The first line of input contains a single integer $$$T$$$, the number of test cases.
Then, $$$T$$$ lines follow, each containing the six space-separated integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$, $$$e$$$, and $$$f$$$, corresponding to the values in each test case that must be answered.
$$$$$$\begin{align*}
&\begin{array}{|l|} \hline \text{Constraints For All Subtasks} \\ \hline 1 \leq T \leq 100 \\ 0 \leq a, b, c \leq 100 \\ 0 \leq d, e, f \leq 10^8 \\ \hline \end{array}\\
&\begin{array}{|c|c|l|} \hline \text{Subtask} & \text{Points} & \text{Constraints} \\ \hline
1 & \mathbf{33} & 0 \leq a, b, c \leq 3 \\ && 0 \leq d, e, f \leq 3 \\ \hline
2 & \mathbf{33} & 0 \leq a, b, c \leq 10 \\ \hline
3 & \mathbf{34} & \text{No further constraints.} \\ \hline
\end{array}\\
\end{align*}$$$$$$
Output $$$T$$$ lines. For each test case, output the following two space-separated values.
3 1 2 3 6 9 2 3 1 1 9 5 1 1 2 3 4 5 6
4 6 5 6 27 0
| Name |
|---|


