Codeforces Round #589 (Div. 2) A. Distinct Digits

Posted ydddd

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #589 (Div. 2) A. Distinct Digits相关的知识,希望对你有一定的参考价值。

链接:

https://codeforces.com/contest/1228/problem/A

题意:

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.

思路:

水题.

代码:

#include <bits/stdc++.h>
using namespace std;

bool Check(int x)

    int vis[10] = 0;
    while (x)
    
        if (vis[x%10] == 1)
            return false;
        vis[x%10] = 1;
        x /= 10;
    
    return true;


int main()

    int l, r;
    cin >> l >> r;
    for (int i = l;i <= r;i++)
    
        if (Check(i))
        
            cout << i << endl;
            return 0;
        
    
    puts("-1");

    return 0;

以上是关于Codeforces Round #589 (Div. 2) A. Distinct Digits的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #589 (Div. 2)

Codeforces Round #589 (Div. 2)

codeforces round 589

Codeforces Round #589 (Div. 2) A. Distinct Digits

Codeforces Round #589 (Div. 2) (ef没写)

Codeforces Round #589 (Div. 2) - A