Advertisement
Guest User

Task CESCA

a guest
Dec 20th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. 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.
  2. Help our hero and write a programme that calculates that number (if it exists).
  3.  
  4. INPUT
  5. The first and only line of input contains the integer N, consisting of at most 10^5 digits.
  6.  
  7. OUTPUT
  8. The first and only line of output must contain the required number from the task, if it exists. If it
  9. doesn’t exist, output -1.
  10.  
  11. SAMPLE TEST DATA
  12. input input input
  13. 30 102 2931
  14. output output output
  15. 30 210 -1
  16.  
  17. Time limit 1 s
  18. Memory limit 32 MB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement