Advertisement
sasa2742002

Untitled

Apr 18th, 2023
963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.12 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #include <ext/pb_ds/assoc_container.hpp>
  4. #include <ext/pb_ds/tree_policy.hpp>
  5. using namespace __gnu_pbds;
  6. #define T     \
  7.   ll rrr;     \
  8.   cin >> rrr; \
  9.   for (ll w1 = 0; w1 < rrr; w1++)
  10. #define cin(vec, a) for (ll i = 0; i < a && cin >> vec[i]; i++)
  11. #define cout(vec, a) for (ll i = 0; i < a && cout << vec[i] << " "; i++)
  12. #define MOD 1000000007
  13. #define PI 3.14159265
  14. #define ceil(a, b) ((a / b) + (a % b ? 1 : 0))
  15. #define all(v) v.begin(), v.end()
  16. #define rall(v) v.rbegin(), v.rend()
  17. #include <iostream>
  18. #define INF 1e9
  19. #define mod 1000000007
  20. #include <string>
  21. #define el '\n'
  22. #define sp ' '
  23. #define loop(n) for (int i = 0; i < n; i++)
  24. typedef long long ll;
  25. #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
  26. #define multi_ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
  27. template <typename O = int>
  28. istream &operator>>(istream &in, vector<O> &v)
  29. {
  30.   for (auto &x : v)
  31.     in >> x;
  32.   return in;
  33. }
  34. template <typename O = int>
  35. ostream &operator<<(ostream &out, const vector<O> &v)
  36. {
  37.   for (const O &x : v)
  38.     out << x << ' ';
  39.   return out;
  40. }
  41. void sasa()
  42. {
  43.   ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  44. #ifndef ONLINE_JUDGE
  45.   freopen("input4.txt", "r", stdin), freopen("output4.txt", "w", stdout);
  46. #endif
  47. }
  48.  
  49. ///////////////////////////////////////// code //////////////////////////////////////////////////////////////////////////
  50. bool isit(ll i)
  51. {
  52.   string s = to_string(i);
  53.   for (ll j = 0; j < s.size() - 1; j++)
  54.   {
  55.     if (abs(s[j] - s[j + 1]) > 1)
  56.       return false;
  57.   }
  58.   return true;
  59. }
  60. void solve()
  61. {
  62.   ll k, res = 0;
  63.   cin >> k;
  64.   for (ll i = 1; i < ll(1e5 + 1); i++)
  65.   {
  66.     ll temp = isit(i);
  67.     if (temp)
  68.       res++;
  69.     if (res == k)
  70.     {
  71.       cout << i << el;
  72.       return;
  73.     }
  74.   }
  75. }
  76.  
  77. int main()
  78. {
  79.   sasa();
  80.  
  81.   ll t = 1, i = 1;
  82.   // cin >> t;
  83.   while (t--)
  84.   {
  85.     // cout << "test #" << i << ":\n";
  86.     solve();
  87.     i++;
  88.     if (!t)
  89.       break;
  90.     // cout << "\n";
  91.   }
  92.  
  93.   return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement