Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
  5.  
  6. const int maxN = 1e5 + 1;
  7.  
  8. int main() {
  9.   FASTIO;
  10.   int k;
  11.   cin >> k;
  12.   vector<string> v;
  13.   //adj[0].push_back(1), adj[1].push_back(0), adj[1].push_back(2), adj[2].push_back(1);
  14.   v.push_back("1"), v.push_back("2"), v.push_back("3"), v.push_back("4"), v.push_back("5"), v.push_back("6"), v.push_back("7");
  15.   v.push_back("8"), v.push_back("9");
  16.   int wtf = 0;
  17.   string now = "";
  18.   for (int i = 10; i < maxN; i++) {
  19.     now = v[wtf];
  20.     int n = (int) now.size();
  21.     int aux = (now[n - 1] - '0');
  22.     string sos = now;
  23.     aux--;
  24.     int d = (now[n - 2] - '0');
  25.     if (aux >= 0) {
  26.       now += (aux + '0');
  27.       v.push_back(now);
  28.     }
  29.     aux++;
  30.     now = sos;
  31.     if (aux <= 9) {
  32.       now += (aux + '0');
  33.       v.push_back(now);
  34.     }
  35.     aux++;
  36.     now = sos;
  37.     if (aux <= 9) {
  38.       now += (aux + '0');
  39.       v.push_back(now);
  40.     }
  41.     wtf++;
  42.   }
  43.   cout << v[k - 1] << endl;
  44.   return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement