开始前有必要说一下,这才第二题就碰到了烂尾题,以自己开始的思路交了n次,错了n词,最后才19分,后来看了一下大佬的c++代码(尽然没有c的代码),还好c和c++的差别不是特别大,仔细琢磨一遍后突然发现很多地方可以改进,整理思路在此尝试终于AC,这才第二题啊。。。。
This time, you are supposed to find A+B where A and B are two polynomials.
Input Specification:
Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:
K N1 aN1 N2 aN2 ... NK aNK
where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1,2,⋯,K) are the exponents and coefficients, respectively. It is given that 1≤K≤10,0≤NK<⋯<N2<N1≤1000.
Output Specification:
For each test case you should output the sum of A and B in one line, with the same format as the input. Notice that there must be NO extra space at the end of each line. Please