I would cherish if someone would share an idea on how to solve the Simple Algebra Problem.
You are given a mathematical function f(x) and a value of a. Your task is to determine if the equation
f(x) = a has a solution in real numbers. Although this problem may seem simple at first, be prepared
for a challenge, as the function you are given is longer and much more complex than what you may have
encountered in a typical algebra class.
The function is a big composition of exp(x) and log(x) functions. For a clearer understanding, refer to
the examples provided.
The exponential function exp(x) or e^x raises the constant e (approximately equal to 2.718281828459045)
to the power of x, while the logarithmic function log(x) gives the power to which e must be raised to
obtain the value x.
Input
The first line of input contains a string that represents the given function. It is a composition of between
1 and 10^5 exp(x) and log(x) functions.
More specifically, exp(x) and log(x) are valid functions, and if f(x) is a valid function, so are exp(f(x))
and log(f(x)).
The second line of input contains a decimal number a (−10^9 ≤ a ≤ 10^9), given with exactly two decimal places.
Output
Print “Yes” if f(x) = a has a solution in real numbers, or “No” otherwise.
Examples
standard input standard output
exp(exp(x)) No
0.50
log(log(exp(log(x)))) Yes -2.39 exp(x) No 0.00 exp(log(x)) No 0.00
log(log(exp(log(x)))) Yes -2.39 exp(x) No 0.00 exp(log(x)) No 0.00
1 Reply