Cubic polynomials
시간 제한1.5초메모리 제한256 MB
계수가 0이 아닌 정수인 삼차방정식 n개가 주어질 때, 곱의 근이 되는 정수 중 중복도가 가장 큰 값을 찾는다.
문제
Two old pals, Cardanieux and Ferrarineux, love mathematical competitions: one of them emails the other a mathematical problem, with week to solve it. If the friend fails to cope with the problem in a week, he loses.
Ferrarineux came up with yet another problem and has already sent it to his friend. Cardanieux has just read the new challenge --- he's got a big pile of cubic equations of the shape , and the challenge is to multiply all this polynomials and find an integer, such that it is root of the largest multiplicity of the product. Cardanieux is very worried: he has lost three times in a row. This time, he just cannot afford to lose. He is asking you to write a program which will find a solution to the challenge, so that he can disappoint his friend with a lighting-fast correct answer.
입력
The first line of the input file contains a single integer --- the number of the equations (). It is followed by lines, with each th line containing four integers , , and , which are all non-zero --- the coefficients of the th equation ().
It is guaranteed that all numbers are non-zero.
출력
If none of the equations has an integer root, print a single line NO. Otherwise, in the first line of the input file, print the YES. In the second line, print two space-separated integers --- the first one is the root of the largest multiplicity of the product of these equations, and the second one is the multiplicity.
If there are several solutions, print any of them.
힌트
In the first example the product of the polynomials equals
\begin{equation\*} (x^3 + 3x^2 + 3x + 1) \cdot (2 x^3 + 2 x^2) = 2 x^2 (x + 1)^4 \end{equation\*}
The number 0 is a root of multiplicity 2 and the number -1 is a root of multiplicity 4.
In the second example there are no integer roots.