CF1228A.Distinct Digits

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have two integers ll and rr . Find an integer xx which satisfies the conditions below:

  • lxrl \le x \le r .
  • All digits of xx are different.

If there are multiple answers, print any of them.

输入格式

The first line contains two integers ll and rr ( 1lr1051 \le l \le r \le 10^{5} ).

输出格式

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, 123123 is one of the possible answers. However, 121121 can't be the answer, because there are multiple 11 s on different digits.

In the second example, there is no valid answer.

首页