| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11408 | Polynomial Computation |
|
| 11407 | Matrix Computation |
|
Description
Create a class Polynomial. The internal representation of a Polynomial is an array of terms. Each term contains a coefficient and an exponent, e.g., the term 2x4 has the coefficient 2 and the exponent 4.
Provide public member functions that perform each of the following tasks:
- Adding two Polynomial.
- Subtracting two Polynomial.
- Multiplying two Polynomial.
Input
There are four lines.
The first two lines represent the greatest power and the corresponding coefficients of the first polynomial.
The last two lines represent the greatest power and the corresponding coefficients of the second polynomial.
The greatest power is in the range of 0-25.
Note that the coefficients are in descending order and each element is separated by a space.
Output
Output the coefficients of the sum, difference and product of these two polynomials in descending order.
If the result of coefficient is 0, just print it.
ex:
2
1 2 1
0
0
The answer will be :
1 2 1
1 2 1
0 0 0
Note that there is a new line character at the end of each answer.
Sample Input Download
Sample Output Download
Partial Judge Code
11408.cppPartial Judge Header
11408.hTags
Discuss
Description
Create a class Matrix to represent a N * N matrix.
Provide public member functions that perform the following tasks:
- Matrix addition.
- Matrix subtraction.
- Matrix Multiplication.
- Adding cell value by 1 (module 10). That is, if after adding 1, a cell value becomes 10 we change it to 0.
- Matrix Transpose.
Input
The first line has an integer N (1<=N<=50), which means the size of the matrix. The total number of elements in the matrix is thus N * N.
For the next 2N lines:
- The first N lines specify the elements of the first matrix a.
- The following N lines specify the elements of the second matrix b.
All elements in matrix are in the range of 0-9.
All elements in the same line are separated by a space.
Output
Output the answer of each task.
In the matrix, all of the integers in the same line are separated by a space, and a newline character at the end of the line.
Ex:
1 2 3"\n"
4 5 6"\n"
7 8 9"\n"
Note : In main function, there is already a newline character between each matrix.