Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created February 21, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/f0879eca262ccb0d5fa7 to your computer and use it in GitHub Desktop.
Save ik11235/f0879eca262ccb0d5fa7 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[])
{
long long int n;
cin>>n;
vector<long long int> ans;
long long int j=max((long long int)0,n-181);
for (; j <= n; j++) {
bool flag=false;
long long int tmp=j,sum=0;
while (tmp>0) {
sum+=tmp%10;
tmp/=10;
}
if(sum+j==n)
ans.push_back(j);
}
cout<<ans.size()<<endl;
for (int i=0; i<ans.size(); i++) {
cout<<ans[i]<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment