Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Equation
Time Limit: 5000MSMemory Limit: 65536K
Total Submissions: 691Accepted: 130Special Judge

Description

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.

Input

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.

Output

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.

Sample Input

#14 X * 2 + 2 /
#22 2 *
#30 2 X / *

Sample Output

#1X = -1/2
#2NONE
#3MULTIPLE

Source

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator