Created
July 12, 2019 12:16
-
-
Save surinoel/7b4e3334cbf81e447162594a2744c075 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
int n; | |
cin >> n; | |
vector<int> v = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; | |
vector<int> ans; | |
for (int i = 1; i < (1 << 10); i++) { | |
long long sum = 0; | |
for (int j = 0; j < 10; j++) { | |
if (i & (1 << j)) { | |
sum = sum * 10 + v[j]; | |
} | |
} | |
ans.push_back(sum); | |
} | |
if (n >= ans.size()) { | |
cout << -1 << '\n'; | |
return 0; | |
} | |
sort(ans.begin(), ans.end()); | |
cout << ans[n] << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment