TORONTO KIDS COMPUTER CLUB | PMCA Sunday 10:00 Practice -05.30
post-template-default,single,single-post,postid-19529,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

PMCA Sunday 10:00 Practice -05.30

01 Jun PMCA Sunday 10:00 Practice -05.30

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).

Input Specification
The first and only line of input contains the integer N, consisting of at most 105 digits.

Output Specification
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

Sample Output 1

Sample Input 2

Sample Output 2

Sample Input 3

Sample Output 3
No Comments

Sorry, the comment form is closed at this time.