清华考研机试 10进制 VS 2进制 高精度 进位制
🍑 算法题解专栏
🍑 BigInteger
import java.util.*;
import java.math.BigInteger;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String s = sc.next();
//十进制的字符串 --> bigInteger --> 二进制的字符串
s = new BigInteger(s, 10).toString(2);
int n = s.length();
String res = "";
for (int i = n - 1; i >= 0; i--)
res += s.charAt(i);//字符串拼接
// 二进制的字符串 --> BigInteger --> 十进制的字符串
s = new BigInteger(res, 2).toString(10);
System.out.println(s);
}
}