#P7042. 「MCOI-03」正方

    ID: 5816 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟计算几何O2优化洛谷月赛

「MCOI-03」正方

Description

Given a square, find how many points inside the square satisfy that the ratio of the areas of the four parts divided by the four vertices of the square is a:b:c:da:b:c:d. The four numbers are unordered.

For example, as shown in the figure below, suppose there is a point EE such that the area ratio of the four triangles is a:b:c:da:b:c:d, then point EE meets the requirement. Since the order does not matter, a ratio like d:b:a:cd:b:a:c is also acceptable. However, point EE is not the only solution; you need to output the number of solutions.

Since little S, little Q, little U, little A, little R, and little E like asking questions very much, this problem provides qq queries.

Input Format

The first line contains an integer qq, representing the number of queries.
The next qq lines each contain four integers a,b,c,da,b,c,d.

Output Format

Output qq lines, each line containing an integer representing the answer.

3
1 3 3 1
2 4 7 8
2 3 1 4
4
0
8

Hint

Constraints

For 20%20\% of the testdata, a=b=c=da=b=c=d.
For 100%100\% of the testdata, 1a,b,c,d9×10181 \le a,b,c,d \le 9 \times 10^{18}, 1q1001 \le q \le 100. It is not guaranteed that a:b:c:da:b:c:d is in simplest form, and it is not guaranteed that a,b,c,da,b,c,d are in increasing order.

Translated by ChatGPT 5