Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main(void) {
  8. ios_base::sync_with_stdio(false);
  9. cin.tie(nullptr);
  10.  
  11. int n;
  12. cin >> n;
  13. vector<int> v = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
  14. vector<int> ans;
  15. for (int i = 1; i < (1 << 10); i++) {
  16. long long sum = 0;
  17. for (int j = 0; j < 10; j++) {
  18. if (i & (1 << j)) {
  19. sum = sum * 10 + v[j];
  20. }
  21. }
  22. ans.push_back(sum);
  23. }
  24.  
  25. if (n >= ans.size()) {
  26. cout << -1 << '\n';
  27. return 0;
  28. }
  29. sort(ans.begin(), ans.end());
  30. cout << ans[n] << '\n';
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement