# PAT (Advanced Level) 1023 Have Fun with Numbers (20分)JAVA实现

## tips

with no duplication 没有重复
permutation 排列
given number 给定的数字
original number 原来的数字

1234567899

## Sample Output:

Yes
2469135798

import java.math.BigInteger;
import java.util.Scanner;

public class _1023_Have_Fun_with_Numbers {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String temp = sc.nextLine();
// while(true) {
char[] charA = temp.toCharArray();
BigInteger big = new BigInteger(temp);
BigInteger multiply = big.multiply(new BigInteger(2 + ""));
String target = multiply + "";
char[] charB = target.toCharArray();
if (charA.length != charB.length) {
System.out.println("No");
} else {
String s = "";
for (int i = 0; i < charA.length; i++) {
for (int j = 0; j < charB.length; j++) {
if (charA[i] == charB[j]) {
charA[i] = 's';
s += "s";
break;
}
}
}
// String.valueOf(charA)将char[]转为String
if (String.valueOf(charA).equals(s)) {
System.out.println("Yes");
} else {
System.out.println("No");
}

}
System.out.println(multiply);

// }

}
}

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客