#P7701. [2019年杭电多校]equation
[2019年杭电多校]equation
equation
Problem Description
You are given two integers and two integer sequences and of length . The sequences are indexed from to . Please solve the following equation for : , where means the absolute value of .
Input
The first line contains an integer indicating there are tests. Each test consists of lines. The first line contains two integers . The -th line of following lines consists of two integers .
- only tests with larger than
Output
For each test, output one line. If there are an infinite number of solutions, this line consists only one integer . Otherwise, this line first comes with an integer indicating the number of solutions, then you must print fractions from the smallest to the largest indicating all possible answers. (It can be proved that all solutions can be written as fractions). The fraction should be in the form of "a/b" where a must be an integer, b must be a positive integer, and . If the answer is , you should output "0/1".
Sample Input
4
2 3
1 2
1 -1
3 3
2 1
2 2
2 3
2 1
3 5
4 -1
3 2
1 -1
1 -2
1 -3
Sample Output
-1
2 -3/2 -1/2
0
1 2/1
Source
2019 Multi-University Training Contest 5