Victor's Various Adventures - Victor Writes A Math Contest

View as PDF

Submit solution


Points: 7
Time limit: 3.0s
Memory limit: 256M

Author:
Problem types

This is problem 4 of the Victor's Various Adventures problem set.

Victor is writing a math contest, and easily solves all of the problems. However, he wants to test you with a very easy problem that was on the contest. To make it even easier for you, he has decided that you can write a program to solve the problem. The problem is as follows:

We define an expression as something that can be evaluated to a real number, or is directly one (meaning that it is already a number). An expression is always surrounded by parenthesis ().

Two expressions can be combined to form a nested expression with an operator.

For example, the number ( 11 ) is a direct expression, and the nested expression ( ( 11 ) + ( ( 49 ) + ( 33 ) ) ) can be evaluated to a real number if the + operator is defined.

We will define 3 basic operations:

Operator Operation
! If the left input is larger than the right, apply addition. Otherwise, apply subtraction.
@ If the left input is larger than the right, apply subtraction. Otherwise, apply addition.
$ Compute the result with the following formula: \sqrt{L^{2} + R^{2}}, where L is the left input, and R is the right input.

To prove your brilliance to Victor, can you solve the problem?

Input Specification

On the first and only line, there will be a valid expression, as specified above. The line will end with the = character.

It is guaranteed that all of the numbers in the input are non-negative.

Output Specification

Output the evaluated result to one decimal place.

Sample Input

( ( 4 ) ! ( 11.45 ) ) =

Sample Output

-7.4

Explanation for Sample Input 1

In this sample, since 4 < 11.45, we apply subtraction.

( ( 4 ) ! ( 11.45 ) ) = 4 - 11.45 = -7.45

Sample Input 2

( ( ( 1.2 ) $ ( 5531 ) ) @ ( ( ( 11 ) ! ( 0.1 ) ) $ ( 44.01 ) ) ) =

Sample Output 2

5485.6

Comments

There are no comments at the moment.