ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Linear Data Structures: Arrays > задача:


50442 - Polynomial Addition

Гость
• Вопросы к жюри (1)

Задачи раздела

• 51088 - Number of letters
• 50913 - Manhattan Distance
• 51125 - Filling an Array 3
• 50824 - Sum of Group Maxes
• 50449 - The biggest result
• 51172 - The biggest Minute
• 51085 - xyx Divisible by k
• 51087 - Are they the same?
• 50442 - Polynomial Addition
• 51015 - Student Scholarships
• 50982 - A thief in labyrinth
• 51091 - Guess the number - 1
• 51008 - Sum of Regional Maxes
• 50989 - Rectangles and Points
• 51020 - Number of nodes removed
• 50932 - Shifting rows and columns
• 51141 - Most valuable stock items

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Polynomial Addition

In general, polynomials are represented in the form (see the figure on right)

where there are variables with different non-negative integer exponents and each is multiplied with a coefficient. Polynomials involve only the operations of addition, subtraction, and multiplication.

e.g. the following is a quadratic polynomial (of variable x),
   2x2 - 4x + 7
which can be represented in the form
   2 2 -4 1 7 0

Question: Write a program that accepts two polynomils and returns sum of them.

Input specification
You will be first given two integers (n and m) where n is the length of the first and m is the length of the second polynomial.
The second line will contain n number pairs (coefficient and exponent) for the first polynomial. And, the third line will contain m number pairs for the second polynomial where 1 ≤ (n, m) ≤ 20 and coefficients are between -1000 and 1000 and exponents are between 0 and 20.
Note: Polynomials can be in any order.

Output specification
Show the resulting polynomial in descending order exponents.
 Note: Show information for any coefficient different than 0.

 Sample Input   
 3 3
 1 0 -5 8 3 14
 8 14 -3 10 9 8
 Sample Output   
 11 14 -3 10 4 8 1 0


Для отправки решений необходимо выполнить вход.

www.contester.ru