Honkai: Star Rail is a game where players may encounter a puzzle called the Navigation Compass when arriving at Xianzhou Luofu. This puzzle consists of three layers, each with an orange line.
This puzzle aims to align all the orange lines with the blue line by rotating the layers clockwise. As the layers are rotated, the orange lines will shift position, but the blue line remains fixed. Due to astronomical reasons, the degree to which each layer can be rotated in a single step is predetermined. For instance, if layer $$$1$$$ can rotate by 60° per step, it will take $$$6$$$ steps to complete a full rotation.
Mr. Wor is stuck on the final level of this puzzle, where the player is only allowed to rotate any two layers simultaneously in each step. Given the initial positions of the orange lines and the number of steps required for each layer to complete a full rotation, please find the minimum number of steps required to align all the lines.
In other words, you are given $$$6$$$ integers $$$x_0,x_1,x_2,y_0,y_1,y_2$$$, please find three nonnegative integers $$$t_0,t_1,t_2$$$, such that $$$x_0 + t_1 + t_2 \equiv 0 (\bmod y_0),x_1 + t_0 + t_2 \equiv 0 (\bmod y_1),x_2 + t_0 + t_1 \equiv 0 (\bmod y_2)$$$, and minimize $$$t_0 + t_1 + t_2$$$.
The first line contains one integer $$$T(1 \leq T \leq 10)$$$, denoting the number of test cases.
Then in the next $$$T$$$ lines, each line contains $$$6$$$ integers $$$x_0,x_1,x_2,y_0,y_1,y_2(\forall i, 0 \leq x_i \lt y_i \leq 2000)$$$.
For each test case, print the minimum value $$$t_0 + t_1 + t_2$$$. If there is no solution, print $$$-1$$$.
31 1 1 2 3 41 1 0 2 3 41 1 1 4 7 5
3 5 9
| Название |
|---|


