Created
July 12, 2019 12:18
-
-
Save surinoel/cb0e59747d9c02c554a370dd1a613033 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); | |
vector<int> v = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; | |
int n; | |
cin >> n; | |
vector<long long> 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); | |
} | |
sort(ans.begin(), ans.end()); | |
if (n > ans.size()) { | |
cout << -1 << '\n'; | |
} | |
else { | |
cout << ans[n - 1] << '\n'; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment