Notice that number 123456789 are a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we'll obtain 246913578, which happens to being another 9-digit number consisting exactly the numbers from 1 to 9, Only in a different permutation. Check to see the result if we double it again!
Now is suppose to check if there is more numbers with the This property. That's, double a given number with k digits, if the resulting number consists of only a permutation of th e digits in the original number.
Input Specification:
Each input file contains the one test case. Each case contains one positive integers with no more than digits.
Output Specification:
For each test case, first print in a line "Yes" if doubling the input number gives a number this consists of only a Permut Ation of the digits in the original number, or "No" if not. Then on the next line, print the doubled number.
Sample Input:
1234567899
Sample Output:
Yes2469135798
I don't know why there's a case like that.
1 ImportJava.math.BigInteger;2 ImportJava.util.Scanner;3 4 Public classA {5 6 Public Static voidMain (string[] args) {7Scanner cin =NewScanner (system.in);8BigInteger A =Cin.nextbiginteger ();9BigInteger BB =A;TenBigInteger C = biginteger.valueof (10); One BigInteger D; ABigInteger ans =A.add (BB); -BigInteger B =ans; - BooleanBook =true; the int[] Book0 =New int[10]; - while(!a.equals (biginteger.valueof (0))) { - //System.out.println (a.equals (0)); -D =A.mod (c); +A =A.divide (c); -Book0[d.intvalue ()] = 1; + } A while(!b.equals (Biginteger.zero)) { atD =B.mod (c); -b =B.divide (c); - if(Book0[d.intvalue ()]! = 1) { -Book =false; - Break; - } in } - if(Book = =false) { toSystem.out.println ("No"); + } - Else { theSystem.out.println ("Yes"); * } $ System.out.println (ans);Panax Notoginseng - } the +}
Java's large number calculation BigNumber