uCoder | 1207 | Nível: 3 | Tempo Limite: 3
At most twice
Adaptado por Erich Rodrigues
Competição: SBC - ACM/ICPC - Maratona de Programação de 2015 - Final Nacional
Given a positive integer U , find the largest integer L such that L ≤ U and L does not contain any digit more than twice.
Entrada
The input consists of a single line that contains an integer U (1 ≤ U ≤ 1018).
Saída
Output a line with an integer representing the largest number less than or equal to U that does not contain any digit more than twice.
Exemplo de Entrada | Exemplo de Saída |
---|---|
20152015 |
20152015 |
1001223343 |
998877665 |
1000000000000000000 |
998877665544332211 |
2210102960 |
2210099887 |