Contest.uni-smr.ac.ru :: соревнования по программированию
Русская версия || English version
Login:
Password:
Забыли пароль?
 пример поиска: Вася Пупкин
 

Problem A. As simple as it gets

Задачу добавил: elena

Успешно сдано решений: 6

Author: A. Klenin
Input file: input.txt
Output file: output.txt
Time limit: 1 sec
Memory limit: 64 Mb

Statement
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 tests
No.      Sample input      Sample output
 1           111                  0
 2           765437654       765377777

Сдать задачу

Задать вопрос жюри по этой задаче