17 Oct Tuesday Python Homework 18:30 – 22.10.11.
Posted at 11:18h in Tuesday Python 18:30 0 Comments
One morning, completely by chance, Mirko found a positive integer N in the middle of the street. Since Mirko adores the number 30, he wants to know the maximum multiple of the number 30 that can be obtained by shuffling the digits of the number he found in the street. Help our hero and write a program that calculates that number (if it exists).
The first and only line of input contains the integer N, consisting of at most 105 digits.
The first and only line of output must contain the required number from the task, if it exists. If it doesn’t exist, output -1.
Sample Input 1 30 Sample Output 1 30 Sample Input 2 102 Sample Output 2 210 Sample Input 3 2931 Sample Output 3 -1
Sorry, the comment form is closed at this time.