当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
Your task is to solve an equation of the form f(x) = 0 where f(x) is written in postfix notation with numbers, operations +, -, *, /, and at most one occurrence of a variable x.
For example, f(x) for an equation (4x + 2)⁄2 = 0 is written as:
4 X * 2 + 2 /
The solution for f(x) = 0 is x = −1⁄2.
The input file consists of a single line with at most 30 tokens separated by spaces. Each token is either:
The input file contains a correct representation of f(x) in postfix notation where token X occurs at most once. There is no division by a constant zero in this equation, that is, there always exists a value of x, such that f(x) can be evaluated without division by zero.
Write to the output file:
#1 | 4 X * 2 + 2 / |
---|---|
#2 | 2 2 * |
#3 | 0 2 X / * |
#1 | X = -1/2 |
---|---|
#2 | NONE |
#3 | MULTIPLE |
时间上限 | 内存上限 |
5000 | 65536 |