Given the coefficients of a polynomial from degree 8 down to 0, you are to format the polynomial in a readable format with unnecessary characters removed. For instance, given the coefficients 0, 0, 0, 1, 22, -333, 0, 1, and -1, you should generate an output line which displays x^5 + 22x^4 - 333x^3 + x - 1. The formatting rules which must be adhered to are as follows:
The input file will contain one or more lines of coefficients delimited by one or more spaces. There are nine coefficients per line, each coefficient being an integer with a magnitude of less than 1000.
The output file should contain the formatted polynomials, one per line.
範例輸入 1
0 0 0 1 22 -333 0 1 -1 0 0 0 0 0 0 -55 5 0
範例輸出 1
x^5 + 22x^4 - 333x^3 + x - 1 -55x^2 + 5x
Pro 專屬功能: 查看這題在歷屆 CPE 出現過幾次 — 升級以解鎖.