fork download
  1. /*
  2. وَلَا تُخْزِنِي يَوْمَ يُبْعَثُونَ•يَوْمَ لَا يَنفَعُ مَالٌ وَلَا بَنُونَ•إِلَّا مَنْ أَتَى اللَّهَ بِقَلْبٍ سَلِيم❤
  3. */
  4. #include <bits/stdc++.h>
  5. #define ll long long
  6. #define el endl
  7. using namespace std;
  8. void saf_sofa()
  9. {
  10. if (fopen("in.txt", "r"))
  11. {
  12. freopen("in.txt", "r", stdin);
  13. freopen("out.txt", "w", stdout);
  14. }
  15. ios_base::sync_with_stdio(false);
  16. cin.tie(NULL);
  17. }
  18. int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
  19. int dy[] = { -1, 1, 0, 0, -1, 1, 1, -1 };
  20.  
  21.  
  22. void solve()
  23. {
  24. ll l, r;
  25. cin >> l >> r;
  26. for (int i = l; i <= r; i++)
  27. {
  28. int t = i;
  29. bool f = 1;
  30. int freq[26] = {0};
  31. while (t > 0)
  32. {
  33. int m = t % 10;
  34. freq[m]++;
  35. if (freq[m] > 1)
  36. {
  37. f = 0;
  38. break;
  39. }
  40. t /= 10;
  41. }
  42. if (f)
  43. {
  44. cout << i << el;
  45. return;
  46. }
  47. }
  48. cout << -1 << el;
  49. }
  50. int main()
  51. {
  52. saf_sofa();
  53. int t_ = 1;
  54. // cin >> t_;
  55. while (t_--)
  56. {
  57. solve();
  58. }
  59. }
  60. /*
  61.  
  62. وَليتَ الذي بَيني وبينَك عامِرٌ وبَيني وبَينَ العَـٰالمينَ خرَابُ
  63.  
  64. */
Success #stdin #stdout 0.01s 5288KB
stdin
121 130
stdout
123