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

    ID: 1370 Type: RemoteJudge 1000ms 125MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>模拟字符串数学洛谷原创

整式的计算【数据有误】

题目背景

小明上了初中,整式计算总是出错,所以他找到了爱编程的你,让你设计一个程序帮帮他。

题目描述

输入几个单项式或多项式,计算结果。

输入格式

包括+,-,*,字母(只包括a到z26个小写字母)单项式两边没有括号,多项式两边有( )或[ ],保证在每一个因式中,单项式在多项式前面。(长度不超过255)

输出格式

输出这个表达式的结果,每个因式按字典序排列。

Sample Input 1

(a+b)*(a+b+c)

Sample Output 1

a^2+2ab+ac+b^2+bc

Sample Input 2

(a+b)*(a+b+c)

Sample Output 2

a^2+2ab+ac+b^2+bc

Sample Input 3

(2a+b)*(2a-b)

Sample Output 3

4a^2-b^2

Sample Input 4

(a+b)*(a+b)*(a+b)

Sample Output 4

a^3+3a^2b+3ab^2+b^3

Sample Input 5

f*(a+b+d+z)+f^2

Sample Output 5

af+bf+df+fz+f^2

Sample Input 6

(a+b+2c)*(a+b-2c)-(a+b)*(a+b)

Sample Output 6

-4c^2

提示

水题一道。