<PREV Problem:
NEXT>
Solved by 210 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Fraction

Time limit = 5 second(s)

Memory limit = 8 Mb

The language to write down fractions consists of one simple rule.
{a}/{b}
means a fraction, with numerator "a" and denominator "b". Spaces are not allowed in this language.
In order to represent this fraction in text mode with fixed character width, the fraction line is build up from "minus" characters and placed in such way, that numerator is completely above and denumerator — completely below the line. The numerator and denumerator should be placed according to this rule in such way, that the dimensions of the resulting fraction representation are minimal possible. Then two additional "minuses" are added to the fraction line — one on the left and one on the right.
For example, the fraction
{2m}/{{n}/{q}}+{{x}/{y}}/{z+1}
Has the following representation
        x
       ---
 2m     y
-----+-----
  n    z+1
 ---
  q
The dimensions of fraction is this example are 11x7 characters.
Your task is to determine the horizontal and vertical size of the resulting fraction. You don't need to construct the fraction representation itself.

Input The first and only line contains the string with fraction specifiction. The length of te string does not exceed 50 characters.

Output Two numbers separated by one or more spaces — the width and height of the fraction in characters respectively.

Input#1
a
Output#1
1 1
Input#2
{2m}/{{n}/{q}}+{{x}/{y}}/{z+1}
Output#2
11 7
Input#3
{aa+bb+cc}/{3}
Output#3
10 3

Author:
Korolev Dmitry
2 april 2004

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 200ms

SW soft NIX
ID = 54.162.181.75