Advertisement
erfanul007

UVa 640

Apr 13th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. #define read() freopen("input.txt", "r", stdin)
  6. #define write() freopen("output.txt", "w", stdout)
  7.  
  8. map<int,bool>mp;
  9.  
  10. int digitsum(int n)
  11. {
  12. int sum=0;
  13. while(n){
  14. sum+=(n%10);
  15. n/=10;
  16. }
  17. return sum;
  18. }
  19.  
  20. void getself(){
  21. for(int i=1;i<=1000000;i++){
  22. mp[i+digitsum(i)]=true;
  23. }
  24. }
  25.  
  26. int main()
  27. {
  28. getself();
  29. for(int i=1;i<=1000000;i++){
  30. if(!mp[i]){
  31. cout<<i<<endl;
  32. }
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement