Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. string test_case()
  9. {
  10. string input;
  11. cin >> input;
  12. string rev_input = input;
  13. reverse(rev_input.begin(), rev_input.end());
  14. int count = 0;
  15. do
  16. {
  17. count++;
  18. input = to_string(stoul(rev_input) + stoul(input));
  19. rev_input = input;
  20. reverse(rev_input.begin(), rev_input.end());
  21. } while (rev_input != input);
  22. return to_string(count) + " " + input;
  23. }
  24.  
  25. int main()
  26. {
  27. int n;
  28. cin >> n;
  29. while (n--)
  30. {
  31. cout << test_case() << endl;
  32. }
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement