解法一:数字统计+高精度
输入数据范围超过 long
,需要使用高精度。
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
BigInteger N = new BigInteger(in.readLine());
int[] res1 = parse(N);
N = N.multiply(BigInteger.valueOf(2));
int[] res2 = parse(N);
if (Arrays.equals(res1, res2)) {
out.println("Yes");
} else {
out.println("No");
}
out.println(N);
out.flush();
}
private static int[] parse(BigInteger N) {
int[] result = new int[10];
while (!N.equals(BigInteger.ZERO)) {
++result[N.mod(BigInteger.TEN).intValue()];
N = N.divide(BigInteger.TEN);
}
return result;
}
}