#P2379. 整式的计算【数据有误】

整式的计算【数据有误】

Description

Input several monomials or polynomials and compute the result.

Input Format

The expression includes +, -, *, and letters (only the 26 lowercase letters a to z). A monomial has no surrounding brackets; a polynomial is enclosed in ( ) or [ ]. It is guaranteed that, within each multiplicative factor, monomials come before polynomials. The length does not exceed 255.

Output Format

Output the result of the expression, with each factor arranged in lexicographic order.

(a+b)*(a+b+c)
a^2+2ab+ac+b^2+bc
(a+b)*(a+b+c)
a^2+2ab+ac+b^2+bc
(2a+b)*(2a-b)
4a^2-b^2
(a+b)*(a+b)*(a+b)
a^3+3a^2b+3ab^2+b^3
f*(a+b+d+z)+f^2
af+bf+df+fz+f^2
(a+b+2c)*(a+b-2c)-(a+b)*(a+b)
-4c^2

Hint

A simple problem.

Translated by ChatGPT 5