题目描述
Given four numbers convert:
a, a decimal number to the binary equivalent
b, a binary to decimal equivalent
c, decimal to hexadecimal equivalent
d, hexadecimal to decimal equivalent
Example 1:
Input :
a = 6
b = 110
c = 20
d = 2A
Output:
110, 6, 14, 42
Explanation:
(6){10} = (110)2
(110) = (6){10}
(20) = (14){16}
(2A) = (42){10}
Example 2:
Input:
a = 10
b = 111
c = 25
d = FA
Output:
1010, 7, 19, 250
Explanation:
(10) = (1010){2}
(111) = (7){10}
(25) = (19){16}
(FA)} = (250)_{10
Your Task:
You don't need to read input or print anything. Your task is to complete the function convert() which takes three integers a, b, c, and string d as input parameters and returns the converted numbers as an array of four strings.
Expected Time Complexity: O(log(max(a,b,c)) + |d|)
Expected Auxiliary Space: O(1)
Constraints:
1 <= a,c <= 500
1 <= b <= 100000(base 2)
1 <= d <= 100000(base 16)
输入格式
见题面
输出格式
见题面