Think Small
Time limit10sMemory limit512 MB
Multiply two polynomials of degree up to one million and print the xor of all coefficients of the product.
- Level
Medium7 of 10
- Topics
- Divide and conquer, Math
- Solved
- No attempts yet
Problem
Jeongmin has grown up, and his parents now make him work through a well known workbook series called Think Small. The unit he has to study this time is multiplication of polynomials. Jeongmin wants to play games instead, so he offers to share his points if you write the program that multiplies the polynomial by the polynomial for him.
Input
The first line contains the degree of the polynomial and the degree of the polynomial , separated by a space. (, )
The second line contains natural numbers , the coefficients of , so that . ()
The third line contains natural numbers , the coefficients of , so that . ()
Output
Let .
Print the xor of every coefficient, , on the first line. In C or C++ you compute c[0] ^ c[1] ^ ... ^ c[L].
The xor is asked for because printing every would be far too much output. It does not change how the problem is solved.
Hint
If and , then .