#abc372g. G - Ax + By < C
G - Ax + By < C
Score : points
问题陈述
你得到了三个长度为的正整数序列:,,和。
找出满足以下条件的正整数对的数量:
- 对于所有,有。
可以证明,满足条件的正整数对的数量是有限的。
你得到了个测试用例,每个测试用例都需要解决。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given three length- sequences of positive integers: , , and .
Find the number of pairs of positive integers that satisfy the following condition:
- for all .
It can be proved that the number of such pairs of positive integers satisfying the condition is finite.
You are given test cases, each of which should be solved.
Constraints
- The sum of over all test cases is at most .
- All input values are integers.
Input
The input is given from Standard Input in the following format. Here, refers to the -th test case.
Each test case is given in the following format:
Output
Print lines. The -th line should contain the answer for .
Sample Input 1
2
2
1 1 4
1 2 5
1
1 1 2
Sample Output 1
2
0
In the first test case, there are two valid pairs of integers: . Thus, the first line should contain .
In the second test case, there are no valid pairs of integers. Thus, the second line should contain .
Sample Input 2
3
7
138 16011 918976
5478 7748 499926
5234 17727 748589
1157 10511 643136
31200 3005 721285
28839 14469 798851
1933 5378 864127
9
17775 1665 386430
37001 863 922418
9756 4182 746671
12379 9106 807578
3984 4049 640539
25333 9869 780810
20372 7000 688738
16107 11974 827227
10779 10531 770510
5
4916 14132 460944
11856 45422 610561
56014 18216 825793
10363 6220 945356
37418 33866 851593
Sample Output 2
660
995
140