fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <functional>
  5. #include <cstdint>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. uint64_t x; //на всякий случай 64
  12. vector<int> v;
  13.  
  14. while ( cin >> x ) {
  15. v.clear();
  16.  
  17. for (uint64_t t = x; t; t /= 10)
  18. v.push_back(t % 10);
  19.  
  20. auto it = v.crbegin();
  21. for (; it != v.crend(); ++it)
  22. if ( any_of( it + 1, v.crend(), bind2nd( less<int>(), *it ) ) )
  23. break;
  24. if (it == v.crend()) cout << "OK: " << x << endl;
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 2988KB
stdin
123456 999 909090 978531.
stdout
OK: 123456
OK: 999