CF1228A.Distinct Digits
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
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.
你有两个整数 l 和 r。请找出一个满足以下条件的整数 x:
- l≤x≤r。
- x 的所有数字互不相同。
如果存在多个答案,输出任意一个即可。
输入格式
The first line contains two integers l and r (1≤l≤r≤105).
第一行包含两个整数 l 和 r(1≤l≤r≤105)。
输出格式
If an answer exists, print any of them. Otherwise, print −1.
如果存在答案,输出任意一个即可;否则输出 −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 1s on different digits.
In the second example, there is no valid answer.
在第一个例子中,123 是一个可能的答案。然而,121 不能作为答案,因为不同数位上存在多个 1。
在第二个例子中,不存在有效的答案。
输入解题思路,AI测评打分。不知道怎么写?