Logo
(追記) (追記ここまで)

33038번 - Legacy Screensaver 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB27201386.667%

문제

On a very old operating system, a screensaver consists of two rectangles flying around the screen. The screen is $W$ pixels wide and $H$ pixels high. Consider the origin to be in the top-left corner of the screen, the $x$-axis to go from the origin to the right, and the $y$-axis to go from the origin to the bottom.

Rectangle $i$ ($i = 1, 2$) has a width of $w_i$ pixels, a height of $h_i$ pixels, initially its top-left corner has coordinates $(x_i, y_i),ドル and its initial movement direction is $(\delta x_i, \delta y_i),ドル where each of $\delta x_i$ and $\delta y_i$ is either $-1$ or 1ドル$. At the end of each second, rectangle $i$'s top-left corner coordinates instantly change by $(\delta x_i, \delta y_i)$.

Whenever rectangle $i$ touches the left or the right border of the screen, the value of $\delta x_i$ changes sign before the next second. Similarly, whenever rectangle $i$ touches the top or the bottom border of the screen, the value of $\delta y_i$ changes sign before the next second. Whenever rectangle $i$ touches two borders of the screen at the same time (which can only happen at the corner of the screen), both $\delta x_i$ and $\delta y_i$ change sign.

As a result of the above, both rectangles stay fully within the screen at all times. Informally, collisions of the rectangles with the screen borders are perfectly elastic. Note, however, that rectangle movement is still discrete: each rectangle moves instantly by 1ドル$ pixel in both directions at the end of each second.

You are curious how often these two rectangles overlap. The rectangles are considered to be overlapping if their intersection has a positive area.

Let $f(t)$ be the number of integers $\tau = 0, 1, \ldots, t - 1$ such that the rectangles overlap during second $\tau$ (where second 0ドル$ is before the rectangles start moving).

Find the limit of $\frac{f(t)}{t}$ as $t \rightarrow \infty$ as an irreducible fraction. It can be shown that this limit is a rational number.

입력

Each test contains multiple test cases. The first line contains the number of test cases $T$ (1ドル \le T \le 1000$). The description of the test cases follows.

The first line of each test case contains two integers $W$ and $H,ドル denoting the width and the height of the screen (3ドル \le W, H \le 4000$).

The next two lines describe the two rectangles. Each rectangle is described by six integers $w_i,ドル $h_i,ドル $x_i,ドル $y_i,ドル $\delta x_i,ドル $\delta y_i,ドル describing the $i$-th rectangle and denoting its width, its height, the coordinates of its top-left corner, and its initial movement direction (1ドル \le w_i \le W - 2$; 1ドル \le h_i \le H - 2$; 0ドル < x_i < W - w_i$; 0ドル < y_i < H - h_i$; $\delta x_i, \delta y_i \in \{-1, 1\})$.

The sum of the values of $W + H$ across all test cases is guaranteed to not exceed 8000ドル$.

출력

For each test case, print a non-negative integer $p$ and a positive integer $q,ドル separated by a slash ('/') without spaces, meaning that the limit of $\frac{f(t)}{t}$ as $t \rightarrow \infty$ is equal to $\frac{p}{q}$. The fraction must be irreducible --- that is, the greatest common divisor of $p$ and $q$ must be equal to 1ドル$.

제한

예제 입력 1

2
3 3
1 1 1 1 1 1
1 1 1 1 1 -1
5 4
2 2 1 1 -1 -1
2 1 2 2 1 -1

예제 출력 1

1/2
1/3

노트

For the second test case, the state of rectangles during the first few seconds is shown in the following pictures. The rectangles overlap during seconds $\tau = 0$ and $\tau = 6$. Thus, for example, $f(8) = 2$.

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > Northern Eurasia Finals 2024 L번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /