Created
February 21, 2015 14:18
-
-
Save ik11235/f0879eca262ccb0d5fa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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