Advertisement
arujbansal

Untitled

Apr 19th, 2021
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <map>
  5. #include <set>
  6. #include <array>
  7. #include <stack>
  8. #include <queue>
  9. #include <random>
  10. #include <numeric>
  11. #include <functional>
  12. #include <chrono>
  13. #include <utility>
  14. #include <iomanip>
  15. #include <assert.h>
  16.  
  17. using namespace std;
  18.  
  19. void dbg_out() { cerr << endl; }
  20. template<typename Head, typename... Tail>
  21. void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
  22. #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
  23.  
  24. #define rng_init mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
  25. #define rng_seed(x) mt19937 rng(x)
  26. #define all(x) (x).begin(), (x).end()
  27. #define sz(x) (int) (x).size()
  28. #define int long long
  29.  
  30. const int MXN = 1e5 + 5, INF = 1e9 + 5;
  31.  
  32. int digit_sum(int x) {
  33.     int sum = x;
  34.  
  35.     while (x) {
  36.         sum += x % 10;
  37.         x /= 10;
  38.     }
  39.  
  40.     return sum;
  41. }
  42.  
  43. void solve() {
  44.     int N;
  45.     cin >> N;
  46.  
  47.     vector<int> ans;
  48.  
  49.     for (int i = max(0ll, N - 100); i < N; i++) {
  50.         if (digit_sum(i) == N) {
  51.             ans.push_back(i);
  52.         }
  53.     }
  54.  
  55.     cout << sz(ans) << "\n";
  56.     for (const auto &x : ans)
  57.         cout << x << "\n";
  58. }
  59.  
  60. signed main() {
  61.     ios_base::sync_with_stdio(false);
  62.     cin.tie(nullptr);
  63.  
  64.     int TC = 1;
  65.     // cin >> TC;
  66.     while (TC--) solve();
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement