#C5554. Rearrange to Form Multiple of 3
Rearrange to Form Multiple of 3
Rearrange to Form Multiple of 3
You are given a non-negative integer (n). Your task is to determine if it is possible to rearrange its digits to form a multiple of (3). A number is a multiple of (3) if the sum of its digits is divisible by (3). If a valid rearrangement exists, output "YES" on the first line followed by the largest possible rearranged number (using all the digits) which is a multiple of (3). Otherwise, output "NO".
Note: The rearranged number should be the largest possible. For example, if (n = 123), the largest valid rearranged number is 321 because (3+2+1=6) which is divisible by (3).
inputFormat
The input consists of a single line containing a non-negative integer (n).
outputFormat
If a valid rearrangement exists, print "YES" on the first line and the largest rearranged number on the second line. Otherwise, print "NO" in a single line.## sample
123
YES
321
</p>