Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- string test_case()
- {
- string input;
- cin >> input;
- string rev_input = input;
- reverse(rev_input.begin(), rev_input.end());
- int count = 0;
- do
- {
- count++;
- input = to_string(stoul(rev_input) + stoul(input));
- rev_input = input;
- reverse(rev_input.begin(), rev_input.end());
- } while (rev_input != input);
- return to_string(count) + " " + input;
- }
- int main()
- {
- int n;
- cin >> n;
- while (n--)
- {
- cout << test_case() << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement