CF 271A - Beautiful Year
It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.
Input
The single line contains integer y (1000?≤?y?≤?9000) — the year number.
Output
Print a single integer — the minimum year number that is strictly larger than y and all it's digits are distinct. It is guaranteed that the answer exists.
---------------------------------------------------------------
2013年仿佛就在昨天。 你知道一個(gè)奇怪的事實(shí)嗎? 2013 年是 1987 年之后的第一年,只有不同的數(shù)字。
現(xiàn)在建議您解決以下問題:給定一個(gè)年份數(shù)字,找到嚴(yán)格大于給定年份且只有不同數(shù)字的最小年份數(shù)字。
輸入
單行包含整數(shù) y (1000?≤?y?≤?9000) — 年份數(shù)。
輸出
打印一個(gè)整數(shù)——嚴(yán)格大于 y 的最小年份數(shù),并且它的所有數(shù)字都是不同的。 保證答案存在。
--------------------------------------------
while循環(huán)+函數(shù)判斷即可;
下面是代碼: