printРабочее место участника

printЗадачи

1471. As simple as it gets

Ограничения: время – 1s/2s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Let us define that a positive integer `A` is simpler than a positive integer `B` if the decimal representation of `A` requires less different digits than the decimal representation of `B`.
For example, number 55 is simpler than 12 which in turn is simpler than 123.
Your program will be given a number `N` and must find the largest integer `X` such that `X\ <\ N` and `X` is simpler than `N`.
Input file format
Input file contains integer `N`.
Output file format
Output file must contain integer `X`. If there is no integer simpler than `N`, output file must contain 0 (zero).
Constraints
`1\ ≤\ N\ ≤\ 2^31\ -\ 1`

Sample Input 1

111

Sample Output 1

0

Sample Input 2

765437654

Sample Output 2

765377777
Source: NEERC ICPC, Far Eastern subregion, 2008
loading