Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- long long int rev(long long int x)
- {
- long long int rn = 0;
- for (x ; x>0 ; x/= 10)
- rn = ((rn * 10) + (x % 10));
- return rn;
- }
- int main()
- {
- int T, a;
- long long int P, rP;
- cin >> T;
- while (T--)
- {
- cin >> P;
- a = 1;
- rP = rev(P);
- while (1)
- {
- P = P + rP;
- rP = rev(P);
- if (P - rP == 0)
- {
- cout << a << " " << P << endl;
- break;
- }
- else a++;
- if(a>999) break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement