eolymp
bolt
Try our new interface for solving problems
Məsələlər

Ultimate Finishing Strike

Ultimate Finishing Strike

\includegraphics{https://static.e-olymp.com/content/c7/c706246d1d5aeb484f4f0c4b461db063ba4fc507.jpg} As a ninja, Saito Hajime has to fight many opponents who are foolish enough to challenge his might. Most of these opponents fall easily to Saito's great martial arts techniques and ninjitsus (A ninjitsu is a technique that comes from the ninjas inner power called \textbf{Q_i}.). From time to time however, the great Saito Hajime has to take care of a particularly powerful and skilled foe (In the age of ninjas, such a foe was commonly referred to as Boss.). This foe usually enters the combat after several dozens of his/her minions have been defeated by Saito. Saito always encounters such foes in empty rectangular rooms. In order to defeat such a powerful foe, Saito has to perform a special ninjitsu known as Saito Hajime's Zero Stance Ultimate Finishing Strike. This strike involves hitting his foe by performing a flying kick that starts at Saito's current position. Of course, a simple flying kick will not be enough to defeat a powerful foe, but Saito can improve the power of his strike by bouncing off several walls before hitting his foe. Every bounce gives his attack more power, so that with enough bounces any foe can be defeated. Note that Saito always bounces off a wall according to the rule \\angle of incidence is equal to the angle of reflection". Saito knows how often he has to bounce off a wall to defeat a particular foe. He must be careful though,if his attack takes too long, his foe might be able to dodge his attack. Therefore, the distance traveled by Saito while performing his strike must be as short as possible. Can you figure out how often Saito will hit each of the four walls while performing his strike? \InputFile The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format: \begin{itemize} \item A line with three positive integer numbers \textbf{L}, \textbf{W} (\textbf{3} ≤ \textbf{L}; \textbf{W} ≤ \textbf{100}), and \textbf{B} (\textbf{0} ≤ \textbf{B} ≤ \textbf{10^5}): the length and width of the room, and the number of bounces necessary to defeat his foe. \item A line with two positive integer numbers \textbf{x_S} (\textbf{0} < \textbf{x_S} < \textbf{L}) and \textbf{y_S} (\textbf{0} < \textbf{y_S} < \textbf{W}): the starting coordinates of Saito. \item A line with two positive integer numbers \textbf{x_f} (\textbf{0} < \textbf{x_f} < \textbf{L}) and \textbf{y_f} (\textbf{0} < \textbf{y_f} < \textbf{W}): the coordinates of the foe. \end{itemize} The bottom left corner of the room is at (\textbf{0}, \textbf{0}). You can assume that Saito and his foe do not start at the same position. If Saito hits a corner of the room, this counts as two bounces, one for each wall. Also, Saito is able to fly over his foe while performing his strike. \OutputFile For every test case in the input, the output should contain: \begin{itemize} \item One line with four integers: the number of times Saito has hit the north, east, south, and west wall, respectively. The north wall is in the positive \textbf{y}-direction and the east wall is in the positive \textbf{x}-direction. In case there are multiple possibilities, you must output all of them ordered lexicographically, each on a separate line. \item One line containing the number \textbf{0}. \end{itemize}
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 32 MiB
Giriş verilənləri #1
2
3 3 1
1 1
2 2
6 6 3
3 1
2 4
Çıxış verilənləri #1
0 0 0 1
0 0 1 0
0 1 0 0
1 0 0 0
0
1 0 1 1
0
Mənbə ICPC BAPC 2011 Finals