Polynomial Factoring
https://www.facebook.com/codingcompetitions/hacker-cup/2011/round-1c/problems/B
Question
A polynomial in x of degree D can be written as:
In some cases, a polynomial of degree D can also be written as the product of two polynomials of degrees and , where . For instance,
In this problem, you will be given two polynomials, denoted F and G. Your task is to find a polynomial H such that G * H = F, and each is an integer.
Input Format
You should first read an integer N, the number of test cases. Each test case will start by describing F and then describe G. Each polynomial will start with its degree D, which will be followed by D+1 integers, denoting . Each polynomial will have a non-zero coefficient for its highest order term.
Constraints
Output Format
For each test case, output a single line describing H. If H has degree , you should output a line containing integers, starting with for H. If no H exists such that G*H=F, you should output "no solution".
Sample Inputs:
Last updated