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



最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 董明珠的四句话激励人一生 第️句,如果您没有“慧根”,就要学会“会跟”。 第️句,宁可在一个注定成功的平台上暂时不...
    桃子_a0ed阅读 4,390评论 0 0
  • 哈希表这个数据结构想必大多数人都不陌生,而且在很多地方都会利用到hash表来提高查找效率。在Java的Object...
    shu2man阅读 3,613评论 1 0
  • 2016-10-29 作者:柠七七 想脱你衣服的人很多,愿意给你买衣服的人却很少。 01 朋友小鱼最近挺苦恼的,我...
    柠七七cyndi阅读 4,068评论 11 9

友情链接更多精彩内容