当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3569:Equation

Special Judge 特殊评判
题目描述

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:

  • a digit from 0 to 9;
  • an operation +, -, *, or /;
  • an uppercase letter X that denotes variable x.

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:

  • X = p/q if equation f(x) = 0 has a single solution that can be represented with a simple fraction pq, where p and q are coprime integer numbers and q is positive.
  • NONE if equation f(x) = 0 has no solution;
  • MULTIPLE if equation f(x) = 0 has multiple solutions.
输入样例
#14 X * 2 + 2 /
#22 2 *
#30 2 X / *
输出样例
#1X = -1/2
#2NONE
#3MULTIPLE

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3569

最后修改于 2020-10-29T07:04:51+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000 65536