fork download
  1. #include <bits/stdc++.h>
  2. // #pragma GCC optimize("O3, unroll-loops")
  3. // #pragma GCC target("avx2,bmi,bmi2")
  4. #define fast \
  5.   ios::sync_with_stdio(false); \
  6.   cin.tie(nullptr); \
  7.   cout.tie(nullptr);
  8. #define fi first
  9. #define se second
  10. #define pr pair
  11. #define ll long long
  12. #define ull unsigned long long
  13. #define db double
  14. #define ln '\n'
  15. using namespace std;
  16. const string NAME = "test";
  17. const ll maxn = 1e7 + 67;
  18.  
  19. /*-------------------------------------------------------------*/
  20. bool check(ll num){
  21. ll sum = 0;
  22. while (num != 0)
  23. {
  24. sum += num % 10;
  25. num /= 10;
  26. }
  27.  
  28. return(sum == 10);
  29. }
  30.  
  31. vector<ll> v;
  32. void sang(){
  33. for (ll i = 19; i <= maxn; i++)
  34. {
  35. if(check(i)) v.push_back(i);
  36. }
  37.  
  38. }
  39. int main()
  40. {
  41. fast;
  42. sang();
  43. /*
  44.   freopen((NAME + ".inp").c_str(), "r", stdin);
  45.   freopen((NAME + ".out").c_str(), "w", stdout);
  46. */
  47. auto start = chrono::steady_clock::now();
  48.  
  49. int k;
  50. cin >> k;
  51.  
  52. cout << v[k - 1];
  53.  
  54. auto end = chrono::steady_clock::now();
  55. cerr << "h, Time = " << chrono::duration<double>(end - start).count() << " s\n";
  56. }
  57.  
Success #stdin #stdout #stderr 0.15s 5316KB
stdin
1
stdout
19
stderr
h, Time = 5.0882e-05 s