Problem 3010 --equation

3010: equation

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
You are given two integers N,CN,C and two integer sequences aa and bb of length NN. The sequences are indexed from 11 to NN

Please solve the following equation for xx

∑i=1N|ai⋅x+bi|=C∑i=1N|ai⋅x+bi|=C, where |v||v| means the absolute value of vv.
The first line contains an integer TT indicating there are TT tests. Each test consists of N+1N+1 lines. The first line contains two integers N,CN,C. The ii-th line of following NN lines consists of two integers ai,biai,bi

1≤T≤501≤T≤50 

1≤N≤1051≤N≤105 

1≤ai≤10001≤ai≤1000 

−1000≤bi≤1000−1000≤bi≤1000 

1≤C≤1091≤C≤109 

* only 55 tests with NN larger than 1000
For each test, output one line. 
If there are an infinite number of solutions, this line consists only one integer −1−1
Otherwise, this line first comes with an integer mm indicating the number of solutions, then you must print mm 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 gcd(abs(a),b)=1gcd(abs(a),b)=1. If the answer is 00, you should output "0/1".
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
-1
2 -3/2 -1/2
0
1 2/1

推荐代码 查看3010 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$291 $ms] 淡意的温柔 590712 2020-06-05 08:41:29
内存最少[$8352 $KB] 淡意的温柔 590712 2020-06-05 08:41:29
第一AC 淡意的温柔 590712 2020-06-05 08:41:29
第一挑战 淡意的温柔 590712 2020-06-05 08:41:29

赛题来源/所属竞赛 2019 Multi-University Training Contest 5 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛