CF1228A.Distinct Digits
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have two integers l and r . Find an integer x which satisfies the conditions below:
- l≤x≤r .
- All digits of x are different.
If there are multiple answers, print any of them.
输入格式
The first line contains two integers l and r ( 1≤l≤r≤105 ).
输出格式
If an answer exists, print any of them. Otherwise, print −1 .
输入输出样例
输入#1
121 130
输出#1
123
输入#2
98766 100000
输出#2
-1
说明/提示
In the first example, 123 is one of the possible answers. However, 121 can't be the answer, because there are multiple 1 s on different digits.
In the second example, there is no valid answer.