<PREV Problem:
NEXT>
Solved by 210 users: ...
UserDateAttemptTimeCMSC
sb3ar23 apr 2008Ruby100.02119 
deCart30 oct 2006FPC100.01124 
topspin12 jun 2009Kylix200.02128 
topspin12 jun 2009Kylix300.02128 
topspin14 jun 2009Kylix500.02128 
Romka03 mar 2008FPC100.02131 
evg28115 may 2010Perl100.06138 
bush09 mar 2006Ruby200.02145 
georgy23 aug 2006Perl200.07153 
grenkin30 aug 2005Kylix1?.??154 
bush07 mar 2006Ruby100.02157 
Zhomart21 oct 2006FPC100.01158 
Aydar04 nov 2006Kylix100.01158 
Languages
C++
123
FPC
32
C
20
Kylix
18
Java
12
Ruby
3
Perl
2
Scheme
1
Python
1
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

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 210ms

SW soft NIX
ID = 3.95.139.100