81. Polynomial Sorter

Time Limit: 1 seconds

Memory Limit: 256 MB

Rating: 1200

Problem Statement

Given a polynomial of degree $N$, print each coefficient of its simplest form from the highest power of $x$ (power $N$) to the lowest power of $x$ (power 0).

Input

First line: $N$ $(1 \le N \le {10}^5)$ Second line: Polynomial expression (in string) It is guaranteed that the length of the string containing the polynomial will not exceed ${10}^6$ (Note: The polynomial might not in its simplest form and the powers of $x$ are not in order)

Output

Output the coefficients of the polynomial from highest power to lowest power.

Sample Cases
Sample Input 1:
3
3x^3-6x^2+5x+12

Sample Output 1:
3 -6 5 12


Sample Input 2:
5
23x^5-17x+4x^4+9x^5-1

Sample Output 2:
32 4 0 0 -17 -1
Explanation

The polynomial might have terms of the same power or terms in a different order than usual.

Sources

bronze@HungJan@, silver@isaachew@

Submit | Back