解题思路:没什么特别思路
注意事项:
参考代码:
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String number = sc.next(); for (int i = 1; i <= 30; i++) { String str = new StringBuilder(number).reverse().toString();//反转字符串 BigInteger integer = new BigInteger(number,n).add(new BigInteger(str,n));//进制相加 if (chek(number = integer.toString(n))) { System.out.println(i); return; } } System.out.println("Impossible"); } private static Boolean chek(String arg) {//判断回文 char[] chars = arg.toCharArray(); int left = 0; int right = chars.length-1; while(right-left>1) { if (chars[left++] != chars[right--]) { return false; } } return true; } }
0.0分
1 人评分