[BOJ 11541] At most twice

View as PDF

Submit solution

Points: 3
Time limit: 3.0s
Memory limit: 256M

Problem type
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

Given a positive integer U, find the largest integer L such that L ≤ U and L does not contain any digit more than twice.

입력 형식

The input consists of a single line that contains an integer U (1 ≤ U ≤ 1018).

출력 형식

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.

예제 입력 1

2210102960

예제 출력 1

2210099887

예제 입력 2

1000000000000000000

예제 출력 2

998877665544332211

예제 입력 3

1001223343

예제 출력 3

998877665

예제 입력 4

20152015

예제 출력 4

20152015

Comments

There are no comments at the moment.