#CCBCHMOT0000042. Năm có bốn chữ số phân biệt (Beautiful Year)
Năm có bốn chữ số phân biệt (Beautiful Year)
Beautiful Year
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given four-digit year y, find the smallest integer year strictly greater than y whose four decimal digits are pairwise distinct.
Input
One integer y.
Output
Print the smallest valid year strictly larger than y.
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): .
- Subtask 3 (50%): .
Examples
Example 1
Input
1987
Output
2013
Explanation
Scanning years after 1987, 2013 is the first with four distinct digits.
Example 2
Input
2013
Output
2014
Explanation
The answer must be strictly greater; 2014 is the next valid year.