当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6627:equation

题目描述
You are given two integers $N, C$ and two integer sequences $a$ and $b$ of length $N$. The sequences are indexed from $1$ to $N$.

Please solve the following equation for $x$:

$\sum\limits_{i=1}^{N}|a_i \cdot x + b_i |=C$, where $|v|$ means the absolute value of $v$.
输入解释
The first line contains an integer $T$ indicating there are $T$ tests. Each test consists of $N+1$ lines. The first line contains two integers $N, C$. The $i$-th line of following $N$ lines consists of two integers $a_i, b_i$.

* $1 \le T \le 50$

* $1 \le N \le 10^5$

* $1 \le a_i \le 1000$

* $-1000 \le b_i \le 1000$

* $1 \le C \le 10^9$

* only $5$ tests with $N$ larger than $1000$
输出解释
For each test, output one line.
If there are an infinite number of solutions, this line consists only one integer $-1$.
Otherwise, this line first comes with an integer $m$ indicating the number of solutions, then you must print $m$ 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)=1$. If the answer is $0$, 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
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6627

最后修改于 2020-10-25T23:32:58+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)