Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7. map <int, int> m;
  8. int main(){
  9. int n;
  10. cin >> n;
  11. int cnt = 0;
  12. for (int i = 0;i < n ; ++i) {
  13. string d = to_string ( i);
  14. //cout << d << endl;
  15. reverse(d.begin (), d.end());
  16. //cout << d << endl;
  17. int sum = 0, f = 1;
  18. for (int i = d.size() - 1 ; i >= 0; -- i){
  19. sum += (d[i] - '0') * f;
  20. f *=10;
  21. //cout << sum << " ";
  22. }
  23. // << endl;
  24.  
  25. //cout << d << " ";
  26. //cout << sum << "___" << endl;
  27. if ((sum + i ) == n) {
  28. cnt ++;
  29. }
  30. }
  31. cout << cnt << endl;
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement