10382 - palindrome   

Description

In this problem:

1. you are given a string which consists only of digit characters ‘1’ to ‘9’;

2. reorder the string to form palindromes; (A palindrome (回文) is a word, phrase, number, or other sequence of characters which reads the same backward or forward.)

3. among all the possible palindromes, find the one with the smallest integer value.

 

Consider the following two examples:

EX1: (total digits are even):

Input:       188126447672

Possible palindromes: 214678876412, 124678876421, 421678876124…

Output:  124678876421

 

EX2: (total digits are odd):

Input:      1881264247672

Possible palindromes: 2146782876412, 1246782876421, 4216782876124…

Output:  1246782876421

 

Input

The input is a string which consists only of digit characters ‘1’ to ‘9’. The string length will less and equal then 100.

Output

The output contains two lines. The first line prints out “YES” or “NO” indicating whether the input string can be reordered to form a palindrome. If the output is “YES”, the second line is the smallest palindrome. Otherwise, if the output is “NO”, the second line is the original string.

Remember to print a '\n' at the end of the answer.

Sample Input  Download

Sample Output  Download

Tags




Discuss