COCI 2007/2008, Contest #4
Task VECI
Your program will be given an integer X. Find the smallest number larger than X consisting of the same digits as X.
Input
The first line of input contains the integer X (1 ≤ X ≤ 999 999).
The first digit in X will not be a zero.
Output
Output the result on a single line. If there is no such number, output 0.
Examples
Input156 Output165 |
Input330 Output0 |
Input27711 Output71127 |
All Submissions
Best Solutions
Point Value: 5
Time Limit: 1.00s
Memory Limit: 32M
Added: Aug 02, 2013
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
Well, I did after a night of sleep and learnt something new again: thanks guys for the ever interesting problems :)!
[I hope I am not annoying you, but seeing that you are doing a good work, yet I presume still a hard one, you surely deserve some praise once in a while, ne?]