博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT 1010 Radix
阅读量:2429 次
发布时间:2019-05-10

本文共 1060 字,大约阅读时间需要 3 分钟。


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 N​2, 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


转载地址:http://xsnmb.baihongyu.com/

你可能感兴趣的文章
边缘计算精华问答 | 边缘计算有哪些应用场景?
查看>>
要闻君说:Synergy Research Group首发云基础设施数据,腾讯云v5一把;京东物流发力5G;厉害!阿里挖走贾扬清...
查看>>
数据中台精华问答 | 数据中台和传统数仓的区别是什么?
查看>>
这是一则计算机视觉顶级会议CVPR与腾讯的爆闻,啥?
查看>>
如何用30分钟快速优化家中Wi-Fi?阿里工程师有绝招
查看>>
【C语言】C语言中常用函数源代码【strncpy ,strncat ,strncmp】
查看>>
【Java】【算法练习】题目描述:输入一个整数数组,判断该数组是不是某二叉搜索树的后续遍历的结果。如果是输出yes,不是输出no,数组任意两个数字不相同。
查看>>
【Java】给定一个二叉树和其中的一个节点,请找出中序遍历的下一个节点且返回, 注意:树中的节点不仅包含左右子节点,同时包含父节点的指针。
查看>>
【Java】【多线程】—— 多线程篇
查看>>
【计算机网络】—— TCP/IP篇
查看>>
【Java】【算法】——算法篇
查看>>
【Java】【数据库】知识重点——数据库篇
查看>>
【Java】知识重点——消息队列篇
查看>>
【Java】学习总结 —— HashMap之put()方法实现原理
查看>>
【计算机网络】【TCP】如何讲清楚Tcp的三次握手和四次挥手?
查看>>
【Java】-- Java核心知识点总结
查看>>
【数据库】SQL之重点知识点总结
查看>>
【计算机网络】计算机网络知识总结
查看>>
【Java】【Web】JavaWeb相关知识总结 2018-9-17
查看>>
【数据库】突破单一数据库的性能限制——数据库-分库分表总结 2018-9-20
查看>>