All submissions for this problem are available.
Intelligence Bureau(IB) has found an email conversation between Osama bin Laden and Al-Qaeda People in cryptic language. The email contains some encrypted message and some symbols next to it. IB people were able to decrypt the message containing details of planning for a bomb blast in Mumbai but were unable to decrypt the symbols. They have come to a conclusion that each symbol represents a digit and the decrypted symbols represents the number of seconds remaining for the bomb blast. They have to decrypt the symbols so that they can plan to vacant the site well before time.
They have no idea what each symbol means. They were not sure what each digit means or what base the Al-Qaeda people were using. For example, if Al-Qaeda people wrote “mn5mo888”, they could have meant “31536000” in base 10 -- exactly 1 year or they could have meant “21325444” in base 6 -- 633700 seconds. IB people were sure of 3 things: the number is positive, number never start with zero and Al-Qaeda people were not using unary ( base 1 ).
Help the IB people to determine the minimum possible number of seconds remaining for the bomb blast.
The first line of input contains a single integer, T. T test cases follow. Each test case is a string on a line by itself. The line will contain only characters in the 'a' to 'z' and '0' to '9' ranges (with no spaces and no punctuation), representing the message. The test cases are independent, and can be in different bases with the symbols meaning different things.
For each test case, output a line with the minimum number of seconds before the bomb blasts.
- 1 ≤ T ≤ 100
- 1 ≤ the length of each line < 61
- The answer will never exceed 10^18
Input: 3 11001001 us zig Output: 201 2 11
|Time Limit:||0.1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions