Advertisement
Saleh127

cf 875A

Sep 3rd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; while(t--)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll a,c,d=0,e,f,i,j=0,k,l;
  11. cin>>a;
  12. c=a;
  13. vector<ll>x;
  14. for(i=a;i>=0 && j<82;i--)
  15. {
  16. e=i;
  17. d=0;
  18. while(e)
  19. {
  20. d+=e%10;
  21. e/=10;
  22. }
  23. if(d+i==c)
  24. {
  25. x.push_back(i);
  26. }
  27. j++;
  28. }
  29. if(x.size()==0) cout<<0<<endl;
  30. else
  31. {
  32. sort(x.begin(),x.end());
  33. cout<<x.size()<<endl;
  34. for(i=0;i<x.size();i++)
  35. {
  36. cout<<x[i]<<endl;
  37. }
  38. }
  39.  
  40. return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement