File size: 634 Bytes
c4b0eef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
    回文
*/
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    int n_testcase;
    cin >> n_testcase;

    while (n_testcase--) {
        int step = 0;
        string origin, temp;
        cin >> origin;
        temp = origin;
        reverse(temp.begin(), temp.end());

        do {
            temp = origin = to_string(stoul(temp) + stoul(origin));
            reverse(temp.begin(), temp.end());
            step++;
        } while (temp != origin);

        cout << step << " " << origin << "\n";
    }
    return 0;
}