Cesta
의견: 0
\(4^{th}\) round, December \(20^{th}\), 2014
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 programme that calculates that number (if it exists).
The first and only line of input contains the integer \(N\), consisting of at most \(10^{5}\) digits.
The first and only line of output must contain the required number from the task, if it exists. If it
doesn’t exist, outp\(ut -1\).
SAMPLE TEST DATA
input
input
input
30
102
2931
output
output
output
30
210
-1
30
30
102
210
2931
-1
평가 및 의견
Cesta
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Cesta