Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stack>
- #include <math.h>
- #include <iostream>
- #include <algorithm>
- #include <string.h>
- #include <string>
- #include <set>
- #include <memory.h>
- #include <vector>
- #include <map>
- #include <queue>
- #include <iomanip>
- #include <ctime>
- #include <cassert>
- #define forn(i, n) for (int i = 0; i < int(n); i++)
- #define ll long long
- #define mp(a, b) make_pair(a, b)
- #define sqr(x) ( (x) * (x) )
- #define all(a) a.begin(), a.end()
- using namespace std;
- int cnt = 0;
- void rec(string s, int sz, int pos, int n) {
- if (pos >= sz)
- return;
- for (int i = 0; i < 10; i++) {
- s[pos] = s[s.size() - pos - 1] = '0' + i;
- if (s[0] != '0' && pos == sz - 1)
- cnt++;
- if (cnt == n) {
- cout << s << endl;
- exit(0);
- }
- rec(s, sz, pos + 1, n);
- }
- }
- int main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int t = 1, len = 1;
- int n;
- cin >> n;
- while (1) {
- int sz = (int)(len / 2.0 + 0.5);
- string s = "";
- forn (i, len)
- s += '0';
- rec(s, sz, 0, n);
- len++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement