eolymp
bolt
Try our new interface for solving problems
Problems

Square of difference

Square of difference

Given positive integer $n$. Find and print the square of difference between the maximum and minimum numbers, composed from the digits of number $n$. For example, if given number is $30605$, the maximum number, composed from its digits, is $65300$, and minimum number is $356$ (the minimum is $00356$, but leading zeros are not counted). The required square of difference is $(65300 - 356) *(65300 - 356) = 4217723136$. \InputFile One positive integer $n~(1 \le n \le 10^9)$. \OutputFile Print the required square of difference.
Time limit 1 second
Memory limit 128 MiB
Input example #1
30605
Output example #1
4217723136