-
Title Description:
-
Converts the number of M-binary x to the number output of n-binary.
-
Input:
-
The first line of input consists of two integers: M and N (2<=m,n<=36).
The following line enters a number x,x is the number of M-binary, and now requires you to convert the M-binary number x to the N-binary number output.
-
Output:
-
The number of the N-binary representation of the output x.
-
Sample input:
-
10F
-
Sample output:
-
15
-
-
Tips:
-
The letter portion of the input is uppercase, the output is lowercase, and there is big data.
PackageA;ImportJava.math.BigInteger;ImportJava.util.*; Public classmain{ Public Static voidMain (string[] args) {Scanner cin=NewScanner (system.in); while(Cin.hasnext ()) {intm=Cin.nextint (); intn=Cin.nextint (); String Str=Cin.next (); String B1=NewBigInteger (str,m). toString (n); System.out.println (B1); } cin.close (); } }
Nine degrees OJ topic 1080: Binary conversion (Java) using BigInteger for binary conversion