fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define endl "\n"
  4. using namespace std;
  5.  
  6. bool hasDistinctDigits(int n)
  7. {
  8. set<char> digits_set;
  9. string yearStr = to_string(n);
  10. for (char c : yearStr)
  11. {
  12.  
  13. digits_set.insert(c);
  14. }
  15. if (digits_set.size() == yearStr.size())
  16. {
  17. return true;
  18. }
  19. else
  20. {
  21. return false;
  22. }
  23. }
  24.  
  25. int main()
  26. {
  27. ios_base::sync_with_stdio(false);
  28. cin.tie(NULL);
  29.  
  30. int n;
  31. cin >> n;
  32.  
  33. while (true)
  34. {
  35. n++;
  36. if (hasDistinctDigits(n))
  37. {
  38. cout << n << endl;
  39. break;
  40. }
  41. }
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
32765