解法一:数字统计+高精度

输入数据范围超过 long ,需要使用高精度。

  1. import java.io.*;
  2. import java.math.BigInteger;
  3. import java.util.Arrays;
  4. public class Main {
  5. public static void main(String[] args) throws IOException {
  6. BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  7. PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
  8. BigInteger N = new BigInteger(in.readLine());
  9. int[] res1 = parse(N);
  10. N = N.multiply(BigInteger.valueOf(2));
  11. int[] res2 = parse(N);
  12. if (Arrays.equals(res1, res2)) {
  13. out.println("Yes");
  14. } else {
  15. out.println("No");
  16. }
  17. out.println(N);
  18. out.flush();
  19. }
  20. private static int[] parse(BigInteger N) {
  21. int[] result = new int[10];
  22. while (!N.equals(BigInteger.ZERO)) {
  23. ++result[N.mod(BigInteger.TEN).intValue()];
  24. N = N.divide(BigInteger.TEN);
  25. }
  26. return result;
  27. }
  28. }