Ankit_132

C

Sep 23rd, 2023
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll     long long
  6. #define pb     push_back
  7. #define ppb    pop_back
  8.  
  9. int main()
  10. {
  11.     vector<ll int> v;
  12.  
  13.     string s = "";
  14.  
  15.     function<void(char)> func = [&](char c)
  16.     {
  17.         s.pb(c);
  18.  
  19.         v.pb(stoll(s));
  20.  
  21.         for(char ch=c-1; ch>='0'; ch--)
  22.             func(ch);
  23.  
  24.         s.ppb();
  25.     };
  26.  
  27.     for(int ch='0'; ch<='9'; ch++)
  28.         func(ch);
  29.  
  30.     sort(v.begin(), v.end());
  31.  
  32.     int k;
  33.     cin>>k;
  34.  
  35.     cout<<v[k]<<"\n";
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment