Solved by 87 users: ...
UserDateAttemptTimeCMSC
daniel.ugra`13 jan 2007`Ruby1000.26272
mikelan`02 mar 2012`C500.90336
toshiba2`04 jan 2007`C++800.26394
NIGHTFIT`31 oct 2011`C++1700.22432
NIGHTFIT`31 oct 2011`C++1400.21433
wanghanga_1`04 dec 2006`C++200.64489
fzszjs1z`04 dec 2006`C++500.64489
davidsun`29 may 2008`C++1201.53501
davidsun`29 may 2008`C++1001.51507
toshiba2`04 jan 2007`FPC700.22510
katuxa`19 feb 2011`C++2801.01518
vislipuzly`18 feb 2011`C++301.05518
checkil`19 feb 2011`C++301.06518
NIGHTFIT`31 oct 2011`C++1300.20522
 C++ 56 Kylix 13 FPC 9 Java 7 C 2 Ruby 1 Python 1
` >  >  >  >  >  >  >  >  >  > `

Time limit = 2 second(s)

Memory limit = 33000 Kb

You are given set of equation of the form "X*Y=Z" or "X+Y=Z".

You have to find radix (base of number representation) for which these equations are true.

Input First line of input contains number of equations N, 0 < N ≤ 1000. Each of next N lines contains equation description of form

```X*Y=Z
```
or
```X+Y=Z
```
where X, Y, and Z are positive integer number representations, namely Z, Y and Z are words from B^*, B={0,1,..,9,a,..,z}. Their lengths are less than 11. Letters 'a', 'b', ..,'z' correspond to "digits" 10, 11, .. 35.

If radix can be determined uniquely, then numbers X, Y, Z do not exceed 264 — 1.

Output Output proper radix if it is unique. Output "0" if the radix does not exist. Output "-1" if it exists but not unique.

 Input#1```3 2*2=4 25*25=625 10+10=20 ``` Output#1```10 ```
 Input#2```1 2*2=5 ``` Output#2```0 ```
 Input#3```1 2*2=4 ``` Output#3```-1 ```

Author:
First Moscow Individual Programming Championship, 17 October 2004, MIPT

 © acm.mipt DevGroupThe page was generated in 200ms