Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cassert>
  4.  
  5. using namespace std;
  6.  
  7. int main ()
  8. {
  9. //freopen ("input", "r", stdin);
  10. //freopen ("output1", "w", stdout);
  11.  
  12. int n;cin >> n;
  13.  
  14. assert (1 <= n && n <= 1000000);
  15.  
  16. long long sum = 0LL;
  17. for (int i = 1; i <= n; ++i)
  18. {
  19. int x;cin >> x;
  20.  
  21. assert (1 <= x && x <= 1000000000);
  22.  
  23. int cx = x, nr = 0;
  24. while (cx > 0)
  25. {
  26. nr = nr * 10 + cx % 10;
  27. cx /= 10;
  28. }
  29.  
  30. if (x == nr) sum += 1LL * x;
  31. }
  32. cout << sum << '\n';
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement