No.61 Rebellion
Problem Statement
Two magical girls, Mami and Homura, were engaged in a gunfight in a sealed room of width \(W\) meters and depth \(H\) meters.
Homura stopped time and, at the same moment, fired her last bullet.
In the world of stopped time, only Homura and the bullet can move. When the bullet hits a wall, it reflects at an angle equal to the angle of incidence and keeps flying forever without losing speed.
Let \((Mx, My)\) be the position of Mami, \((Hx, Hy)\) be the position from which Homura fired, and \((Vx, Vy)\) be the velocity vector of the bullet when fired. When time is stopped for \(D\) seconds,
determine whether the bullet can hit Mami within \(D\) seconds.
Here, the sizes of Mami and the bullet are negligible, and Homura is never hit by the bullet.
Figure: Example of a placement
Input
\(Q\)
\(W_{1}\) \(H_{1}\) \(D_{1}\) \(Mx_{1}\) \(My_{1}\) \(Hx_{1}\) \(Hy_{1}\) \(Vx_{1}\) \(Vy_{1}\)
\(W_{2}\) \(H_{2}\) \(D_{2}\) \(Mx_{2}\) \(My_{2}\) \(Hx_{2}\) \(Hy_{2}\) \(Vx_{2}\) \(Vy_{2}\)
\(\ldots\)
\(W_{Q}\) \(H_{Q}\) \(D_{Q}\) \(Mx_{Q}\) \(My_{Q}\) \(Hx_{Q}\) \(Hy_{Q}\) \(Vx_{Q}\) \(Vy_{Q}\)
All input values are integers.
- \(1 \leq Q \leq 10000\) is the number of test cases.
- The \(Q\) lines starting from the second line each give a tuple \(W, H, D, Mx, My, Hx, Hy, Vx, Vy\).
- \(2\leq W, H\leq 15\)
- \(1 \leq D \leq 10^8\)
- \(0 < Mx, Hx < W\)
- \(0 < My, Hy < H\)
- \(-15 \leq Vx, Vy \leq 15\)
- \((Mx, My) \neq (Hx, Hy)\) is guaranteed.
- \((Vx, Vy) \neq (0, 0)\) is guaranteed.
Output
For each test case, print "Hit" if the bullet hits Mami, and "Miss" otherwise. Print a newline at the end.
Sample
Sample 1
Input
5 9 9 74 7 6 4 1 -5 2 7 11 30 5 4 5 10 13 8 15 4 17 10 3 12 3 -3 1 3 9 22 2 2 1 1 13 12 8 11 2 6 5 1 9 -2 -4
Output
Miss Hit Miss Miss Miss
Sample 2
Input
5 2 15 19 1 2 1 4 1 5 5 5 11 3 1 4 2 9 -7 13 6 68 8 2 11 2 -13 0 2 15 90 1 2 1 8 0 -7 11 4 77 9 1 10 1 -6 13
Output
Miss Miss Hit Hit Miss
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。