#Q1228A. Distinct Digits
Distinct Digits
Distinct Digits
题面翻译
你有两个正整数 和 (),请你找出一个满足下列两个条件的正整数 :
- 这个数的各个数位上的数值均不相同
假如有多个满足条件的解 ,输出任意一个均可。如果没有满足条件的解,那么输出。
题目描述
You have two integers and . Find an integer which satisfies the conditions below:
- .
- All digits of are different.
If there are multiple answers, print any of them.
输入格式
The first line contains two integers and ( ).
输出格式
If an answer exists, print any of them. Otherwise, print .
样例 #1
样例输入 #1
121 130
样例输出 #1
123
样例 #2
样例输入 #2
98766 100000
样例输出 #2
-1
提示
In the first example, is one of the possible answers. However, can't be the answer, because there are multiple s on different digits.
In the second example, there is no valid answer.