回分類題庫
d307: (1052cp2_ex7) Polynomial Addition
出處:

Difficulity : 1
Accepted : 60 Times | Submit :417 Times | Clicks : 972
Accepted : 45 Users | Submit : 53 Users | Accepted rate : 85%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2017-04-06 11:49

Content :

You are asked to use linked-list to solve this question.

Input :

There are two polynomials.

It will start with a positive integer, N (0 ≤ N ≤ 100) followed by N Nonnegative integers (all are less than 100) for each.

The first line is the number of input for polynomial.

The second line are coefficients for the polynomial in ascending powers.

Output :

Please print the first polynomial, the second polynomial and the result of addition in descending powers.

Only when the cofficient is positive number will you print the item.  

ex:

2x^5 , 1x^2 -> (o)

0x^5 , 0 -> (x)

Sample Input :

5
7 6 5 2 3
4
2 3 4 8

Sample Output :

3X^4+2X^3+5X^2+6X^1+7
8X^3+4X^2+3X^1+2
3X^4+10X^3+9X^2+9X^1+9

Hint :

Using linked list

Author :

(管理員:cp2ta)

  Solve it!   Status Forum (0)

C++
C
JAVA
83103. nccucs104703019 (8 ms , 413KB)
83419. nccucs105703053 (4 ms , 271KB)
83048. nccucs105703027 (4 ms , 276KB)
82878. nccucs105703011 (4 ms , 268KB)
82765. nccucs103702024 (4 ms , 271KB)
84047. nccucs102703020 (6 ms , 276KB)
86501. nwgs524513cja (101 ms , 252KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡