1010 Radix

1010 Radix (25)(25 分)

Given a pair of positive integers, for example, 6 and 110, can this

equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number

and 110 is a binary number.

Now for any pair of positive integers N1 and N2, your task is to find

the radix of one number while that of the other is given.

Input Specification:

Each input file contains one test case. Each case occupies a line which

contains 4 positive integers:\

N1 N2 tag radix\

Here N1 and N2 each has no more than 10 digits. A digit is less than its

radix and is chosen from the set {0-9, a-z} where 0-9 represent the

decimal numbers 0-9, and a-z represent the decimal numbers 10-35. The

last number "radix" is the radix of N1 if "tag" is 1, or of N2 if "tag"

is 2.

Output Specification:

For each test case, print in one line the radix of the other number so

that the equation N1 = N2 is true. If the equation is impossible, print

"Impossible". If the solution is not unique, output the smallest

possible radix.

Sample Input 1:

6 110 1 10

Sample Output 1:

2

Sample Input 2:

1 ab 1 2

Sample Output 2:

Impossible



最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • 董明珠的四句話激勵人一生 第?句,如果您沒有“慧根”,就要學會“會跟”。 第?句,寧可在一個注定成功的平臺上暫時不...
    桃子_a0ed閱讀 948評論 0 0
  • 哈希表這個數(shù)據(jù)結(jié)構(gòu)想必大多數(shù)人都不陌生,而且在很多地方都會利用到hash表來提高查找效率。在Java的Object...
    shu2man閱讀 610評論 1 0
  • 2016-10-29 作者:檸七七 想脫你衣服的人很多,愿意給你買衣服的人卻很少。 01 朋友小魚最近挺苦惱的,我...
    檸七七cyndi閱讀 801評論 11 9

友情鏈接更多精彩內(nèi)容