Skip to content

Commit 568cf69

Browse files
committed
Codeforces: Distinct Digits
1 parent d5690f7 commit 568cf69

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

‎Codeforces/1228A.cpp‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @file 1228A.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2026-04-25
5+
*
6+
* @copyright Copyright (c) 2026
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#ifndef LOCAL
14+
#define endl '\n'
15+
#endif
16+
17+
bool mem1;
18+
19+
void solve(void) {
20+
int l, r;
21+
cin >> l >> r;
22+
23+
for (int i = l; i <= r; i++) {
24+
int v = i, cnt = 0;
25+
unordered_set<int> digits;
26+
while (v) digits.insert(v % 10), v /= 10, cnt++;
27+
if ((int)digits.size() == cnt) return cout << i << endl, void();
28+
}
29+
30+
cout << -1 << endl;
31+
32+
return;
33+
}
34+
35+
bool mem2;
36+
37+
int main() {
38+
ios::sync_with_stdio(false), cin.tie(nullptr);
39+
#ifdef LOCAL
40+
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
41+
#endif
42+
43+
int _ = 1;
44+
while (_--) solve();
45+
46+
#ifdef LOCAL
47+
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
48+
#endif
49+
return 0;
50+
}

0 commit comments

Comments
 (0)