#C9965. Infix to Postfix Expression Conversion

    ID: 54116 Type: Default 1000ms 256MiB

Infix to Postfix Expression Conversion

Infix to Postfix Expression Conversion

Given an infix arithmetic expression, convert it to its equivalent postfix (Reverse Polish Notation) expression. The expression may contain single-letter operands or digits along with the operators +, -, *, /, and ^. Parentheses can be used to override the default operator precedence.

The operator precedence is defined as follows:

  • \( + \) and \( - \): precedence 1.
  • \( * \) and \( / \): precedence 2.
  • \( ^ \): precedence 3 (note: exponentiation is right-associative).

Your task is to output the correct postfix expression given the input infix expression. Ensure to follow operator precedence and associativity rules.

inputFormat

The input consists of a single line representing the infix expression. There are no spaces between characters.

outputFormat

Output the corresponding postfix expression as a single line.

## sample
A+B
AB+

</p>